fix: allow renames alongside column casts #9854
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>
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 -->
❌ 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.
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>
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 -->
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 -->
✅ 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.
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 -->
Looks reasonable
Approved these changes.
xuanyu-z
lance-gatefixer[bot]
The shared commit validator rejects an ID-preserving rename in the
Mergetransaction used byalter_columnswhen 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_idmetadata 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:
cargo fmt --allcargo clippy --all --tests --benches -- -D warningsFixes #9853
<!-- lance-gatekeeper-fix:v1 agent=1c723357e6895c397895d185a493e7a1 generation=1 -->