← Back to Pull requests

fix: allow renames alongside column casts #9854

Merged
lance-gatefixer[bot] merged 2 files (251 lines) on Oct 10, 2026 03:45 UTC
View on GitHub
lance-gatefixer[bot] lance-gatefixer[bot] commented on Oct 09, 2026 22:13 UTC
Author

The shared commit validator rejects an ID-preserving rename in the Merge transaction used by alter_columns when another alteration casts a column.

Allow renames to unused sibling names while preserving field and parent IDs. Derive shared fields' parents from the schema tree and require their parent_id metadata to agree, preventing a cloned child with stale metadata from moving between parents or publishing an unreadable schema. Keep rejecting field-ID renumbering and reassignment to an existing sibling's name. Casts and renames still commit as one dataset version.

Validation:

  • Four regression cases cover both alteration orders and field-ID modes, two fragments, null values, and reads of the persisted version. All four reproduced the reported error before the fix and now pass.

  • All 16 Merge dataset tests and 38 transaction-validator tests pass, including nested renames and rejection of remapped child IDs and parent moves with stale or corrected metadata. The two new dataset cases verify that rejected moves leave the stored version, schema, and values unchanged after a fresh local reopen, with the old parent retained or dropped.

  • cargo fmt --all

  • cargo clippy --all --tests --benches -- -D warnings
  • Fixes #9853

    <!-- lance-gatekeeper-fix:v1 agent=1c723357e6895c397895d185a493e7a1 generation=1 -->

    Diff: 251 lines (+243 / -8) across 2 files Reviewer: xuanyu-z Review duration: 332m
    All Vouch review confidence checks passed
    Residual risk 0.06 = Change Risk (0.38) × (1 − Review Confidence (0.84)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.38 · 251 lines diff across 2 files
    0.38
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.84 · 5 substantive comment(s)
    0.84
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    84%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.331
    Real PR Conversation Timeline
    11 items
    claude[bot] claude[bot] commented on Oct 09, 2026 22:13 UTC
    Reviewer

    Claude Code Review

    This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

    <sub>Tip: disable this comment in your organization's Code Review settings.</sub>

    lance-gatefixer[bot] lance-gatefixer[bot] commented on Oct 09, 2026 22:16 UTC
    Author

    Blocked: Python Linux 3.14 ARM failed while pulling its build image from Quay, before compiling the repair or running tests.

    The failure remains on head 04415ba0b76df112290cdfaee8ae08e8ea77ddb8. The failed job and logs show docker pull quay.io/pypa/manylinux_2_28_aarch64:latest receiving 502 Bad Gateway at 22:13:58 UTC on October 9, 2026, causing Docker to exit with code 1. Dependency installation and tests were skipped.

    I inspected the job logs, steps, check annotations, and repair diff. The listed failure is an external image-pull failure, so it does not justify a repair change. The repair already uses the current main base; a base merge would not address this failure. No changes were pushed.

    A maintainer can rerun this failed job once the Quay image is available. If rerunning only the failed job is unavailable, rerun the Python workflow on this same head. The resulting check evidence will determine whether further repair is needed.

    <!-- lance-gatekeeper-fix-blocker:v2 agent=1c723357e6895c397895d185a493e7a1 generation=1 head=04415ba0b76df112290cdfaee8ae08e8ea77ddb8 evidence=939c3f59d85e81942b6a8724 -->

    lance-gatekeeper[bot] lance-gatekeeper[bot] commented on Oct 09, 2026 22:28 UTC
    Reviewer

    ❌ Gate recommendation: request changes.

    Keep the rename and cast in one commit, but validate shared fields' parents from the schema tree before allowing renames. The current guard trusts a stale parent_id and allows an external Merge to publish an unreadable dataset version.

    lance-gatekeeper[bot] lance-gatekeeper[bot] commented on code on Oct 09, 2026 22:28 UTC
    Code Review
    rust/lance-table/src/transaction/validate.rs:1
    @@ -855,7 +856,17 @@ fn merge_schema_valid(
             };
             let prior_path = prior_schema.field_path(field.id)?;
             let new_path = new_schema.field_path(field.id)?;
    -        if prior_path != new_path {
    +        // Match siblings by parent id so an ancestor rename does not hide renumbering.
    +        let prior_siblings = prior_schema
    +            .field_by_id(field.parent_id)
    +            .map_or(prior_schema.fields.as_slice(), |parent| {
    +                parent.children.as_slice()
    +            });
    +        if field.parent_id != prior_field.parent_id

    A moved child can retain its original parent_id, so this comparison accepts a parent move even when the old parent is absent from new_schema. In the default field-ID mode, I verified that committing this schema succeeds and same-session reads work, but a fresh Dataset::open fails with Field 'renamed' (id=1) references parent id 0, which must appear earlier in the protobuf field list. If the old parent is retained instead, reopening silently places the field back under that parent, changing the committed schema.

    Derive parent identity from the field's actual ancestry and check that parent_id agrees before permitting the rename. The previous path check rejects this input.

    <details><summary>Reproducer</summary>

    Add this to the existing tests in validate.rs and run cargo test --profile ci -p lance-table gate_9854_move_with_stale_parent_id --lib. On this head, the rejection assertion fails; restoring the previous path check makes it pass. I also ran both retained-parent and dropped-parent variants through Dataset::commit and a fresh local Dataset::open to verify the persisted consequences above.

    #[test]
        fn gate_9854_move_with_stale_parent_id() {
            let schema = LanceSchema::try_from(&ArrowSchema::new(vec![ArrowField::new(
                "s",
                DataType::Struct(vec![
                    ArrowField::new("x", DataType::Int32, true),
                    ArrowField::new("y", DataType::Int32, true),
                ].into()),
                true,
            )])).unwrap();
            let manifest = manifest_with_file_fields(schema.clone(), vec![1, 2]);
            let mut moved = schema;
            let mut child = moved.fields[0].children.remove(0);
            child.name = "renamed".into();
            // Keep the original parent_id, as cloning a Field does.
            moved.fields.push(child);
            moved.validate().unwrap();
            assert_eq!(moved.field_path(1).unwrap(), "renamed");
            assert_eq!(moved.field_by_id(1).unwrap().parent_id, 0);
            let op = Operation::Merge {
                schema: moved,
                fragments: manifest.fragments.as_ref().clone(),
                preserves_nullability: true,
            };
            assert!(validate_operation(Some(&manifest), &op).is_err(),
                "Merge accepted an actual parent move when parent_id was stale");
        }
    

    </details>

    lance-gatefixer[bot] lance-gatefixer[bot] commented on code on Oct 09, 2026 22:37 UTC
    Code Review
    rust/lance-table/src/transaction/validate.rs:1
    @@ -855,7 +856,17 @@ fn merge_schema_valid(
             };
             let prior_path = prior_schema.field_path(field.id)?;
             let new_path = new_schema.field_path(field.id)?;
    -        if prior_path != new_path {
    +        // Match siblings by parent id so an ancestor rename does not hide renumbering.
    +        let prior_siblings = prior_schema
    +            .field_by_id(field.parent_id)
    +            .map_or(prior_schema.fields.as_slice(), |parent| {
    +                parent.children.as_slice()
    +            });
    +        if field.parent_id != prior_field.parent_id

    Addressed in e70e39318. Shared fields now derive their parent identities from the schema tree, require parent_id to agree, and reject actual parent moves. Regression tests cover stale metadata with the old parent retained or dropped and confirm that rejection leaves the persisted dataset unchanged after a fresh reopen. All 58 focused tests pass, including the combined rename-and-cast cases; formatting and full workspace Clippy pass.

    <!-- lance-gatekeeper-fix-feedback:v1 agent=1c723357e6895c397895d185a493e7a1 generation=1 kind=review_comment id=PRRC_kwDOHn_KdM78baAn head=e70e393186a62f2a578db6c0084af1100040a532 -->

    lance-gatekeeper[bot] lance-gatekeeper[bot] commented on code on Oct 09, 2026 22:39 UTC
    Code Review
    rust/lance-table/src/transaction/validate.rs:1
    @@ -855,7 +856,17 @@ fn merge_schema_valid(
             };
             let prior_path = prior_schema.field_path(field.id)?;
             let new_path = new_schema.field_path(field.id)?;
    -        if prior_path != new_path {
    +        // Match siblings by parent id so an ancestor rename does not hide renumbering.
    +        let prior_siblings = prior_schema
    +            .field_by_id(field.parent_id)
    +            .map_or(prior_schema.fields.as_slice(), |parent| {
    +                parent.children.as_slice()
    +            });
    +        if field.parent_id != prior_field.parent_id

    Fixed in e70e39318: shared fields now derive parent identity from their schema ancestry and require parent_id to agree before allowing renames. This rejects the retained-parent and dropped-parent moves that caused the persisted-schema failure.

    <!-- lance-gatekeeper-review-feedback:v2 agent=77598a3ee8f119376e01b4fecd6209bd root=PRRC_kwDOHn_KdM78baAn head=e70e393186a62f2a578db6c0084af1100040a532 action=addressed -->

    lance-gatekeeper[bot] lance-gatekeeper[bot] commented on Oct 09, 2026 22:46 UTC
    Reviewer

    ✅ Gate recommendation: approve.

    The parent-identity finding is fixed. Invalid parent moves are rejected before publication, while the rename and cast remain atomic. No remaining blockers found.

    lance-gatefixer[bot] lance-gatefixer[bot] commented on Oct 09, 2026 22:57 UTC
    Author

    Blocked: Compatibility Tests cannot install the published pylance==14.0.0b10 compatibility environment, independently of the rename-and-cast repair.

    The failure remains on head e70e393186a62f2a578db6c0084af1100040a532. The failed job and logs report 30 failed, 389 passed, 10 skipped. All 30 failures occur during historical-environment installation after three attempts: seven report ResolutionImpossible for pylance==14.0.0b10 together with lance-namespace>=0.11.1,<0.12; 23 report a wheel hash mismatch from the Lance fury.io index, with the received hash equal to SHA256 of empty content. The logs also show an interrupted wheel download. None of these failures reaches a compatibility assertion against the repair.

    I inspected every failed case, the compatibility environment installer, the repair diff, and the current main changes. The installer and package constraints are unchanged by this repair and unchanged on current main; the two newer base commits affect only mem-WAL code. A base merge would not address this evidence. No code changes were pushed.

    A maintainer needs to reconcile the beta wheel's dependency metadata with the compatibility installer's namespace constraint and restore complete, hash-valid wheel downloads, then rerun the failed job on this head. If the published metadata is correct, the dependency mapping can be corrected in a separate compatibility-infrastructure fix; if the package or index is faulty, correct its distribution instead.

    <!-- lance-gatekeeper-fix-blocker:v2 agent=1c723357e6895c397895d185a493e7a1 generation=1 head=e70e393186a62f2a578db6c0084af1100040a532 evidence=e4794d5a21b1a6942fad1f88 -->

    xuanyu-z xuanyu-z approved these changes on Oct 10, 2026 01:02 UTC
    Approved Reviewer

    Looks reasonable

    Xuanwo Xuanwo approved these changes on Oct 10, 2026 03:45 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    lance-gatefixer[bot] lance-gatefixer[bot]
    Labels
    risk: low confidence: 84.1% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 37.5% (MEDIUM) · Higher = larger blast radius
    37.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 84.1% · Lower = rushed or shallow review
    84.1%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 5.9% · Safe to merge
    5.9%