Skip to content

feat: turn on non-reusable field IDs when a dataset is created - #11628

Merged
Xuanwo merged 4 commits into
lance-format:mainfrom
vaibhavdabas16:feat/10684-create-non-reusable-field-ids
Dec 2, 2026
Merged

Xuanwo merged 4 commits into
lance-format:mainfrom
vaibhavdabas16:feat/10684-create-non-reusable-field-ids

Conversation

@vaibhavdabas16

@vaibhavdabas16 vaibhavdabas16 commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Part of #10684 (item 2: a create-time option). Item 1, the Python and Java bindings for migrate_to_non_reusable_field_ids, is #11472.

A new dataset could only get non-reusable field IDs through a separate migration commit after its first write. As the issue notes, a new dataset has no older writers, so the migration's warning about clients that ignore writer feature flags doesn't apply to it.

Changes:

  • WriteParams::enable_non_reusable_field_ids (Rust) and enable_non_reusable_field_ids= on lance.write_dataset (Python).
  • When the write creates the dataset, InsertBuilder commits it with with_non_reusable_field_id_migration_activation(), so the first manifest records the high-water mark and sets FLAG_NON_REUSABLE_FIELD_IDS.
  • CommitBuilder::use_non_reusable_field_ids(bool) (public, in both lance and lance-table-runtime) activates a dataset the commit creates. One-step writes go through it, and it's the opt-in for committing a create staged with execute_uncommitted.
  • execute_uncommitted and execute_uncommitted_stream reject enable_non_reusable_field_ids on a create, before writing any data file, because a transaction can't carry it to the commit.
  • Like enable_stable_row_ids, the option doesn't change an existing dataset. Appends and overwrites keep its setting, because it may have older writers. migrate_to_non_reusable_field_ids stays the way to opt in later.

This adds a public field to WriteParams, so Rust code that builds it with an exhaustive struct literal must set it.

Tests:

  • Rust: test_enable_non_reusable_field_ids_applies_to_new_datasets, with cases create, append_to_existing and overwrite_existing. It checks the high-water mark and writer flag, then adds, drops and re-adds a column. The re-added column gets a fresh ID (2) only on the created dataset, and reuses ID 1 otherwise.
  • Rust: test_staged_create_with_non_reusable_field_ids[stream=false/true]. A staged create with the opt-in is rejected with no data files left behind. A staged create committed with use_non_reusable_field_ids(true) gives the replacement of the dropped highest-ID column a fresh ID.
  • Python: test_write_dataset_enable_non_reusable_field_ids[False/True] covers the same add/drop/add sequence through write_dataset.

Checks run locally:

A new dataset could only get non-reusable field IDs through a separate
migration commit after it was written. Add
WriteParams::enable_non_reusable_field_ids and the same option on
Python's write_dataset. When the write creates the dataset, its first
manifest is activated. A new dataset has no older writers, so the
migration's warning about clients that ignore writer feature flags does
not apply.

Like enable_stable_row_ids, the option does not change an existing
dataset: appends and overwrites keep its setting, and
migrate_to_non_reusable_field_ids remains the way to opt in later.

Part of lance-format#10684.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions github-actions Bot added A-python Python bindings enhancement New feature or request labels Nov 29, 2026

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted source review of 4c3cc0ce. Both InsertBuilder::execute_uncommitted entry points lose the enable_non_reusable_field_ids opt-in on create. do_commit applies it for one-step writes, but the staged Overwrite transaction carries no activation flag. The public lance::dataset::CommitBuilder then creates version 1 with reusable IDs. Its field-ID activation setter is crate-private.

Please support activation on the first commit in the public two-stage path, or reject the opt-in explicitly when returning an uncommitted create. For the supported path, please commit through the public builder, reopen, drop the highest-ID column and verify that its replacement gets a fresh ID. Staged writes in #10684 depend on that identity.

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Nov 29, 2026
A staged create returned by InsertBuilder::execute_uncommitted (or
execute_uncommitted_stream) cannot carry enable_non_reusable_field_ids to
the commit, so committing it through the public CommitBuilder created a
dataset with reusable field IDs.

Add CommitBuilder::use_non_reusable_field_ids, which activates a dataset
the commit creates, and use it for one-step writes too. A staged create
that sets the option on WriteParams is rejected before any data file is
written, pointing to the builder setter.
@vaibhavdabas16

Copy link
Copy Markdown
Contributor Author

Thanks @Xuanwo, confirmed and fixed in 2be6d3f. It now does both: the public two-stage path is supported, and the staged WriteParams opt-in is rejected instead of lost.

  • Supported path: lance::dataset::CommitBuilder::use_non_reusable_field_ids(bool) is public, mirroring use_stable_row_ids, and forwards to the same setter on the runtime CommitBuilder. It activates the dataset the commit creates and is ignored for an existing dataset, where migrate_to_non_reusable_field_ids stays the way in. One-step writes now go through this setter too, instead of the crate-private migration activation.
  • Explicit rejection: a transaction can't carry the opt-in. So InsertBuilder::execute_uncommitted and execute_uncommitted_stream return InvalidInput when WriteParams::enable_non_reusable_field_ids is set on a create, and the error points to CommitBuilder::use_non_reusable_field_ids. The check runs after the context is resolved (a Uri destination may turn out to be an existing dataset) but before any data file is written. Appends and overwrites of an existing dataset are unaffected.

Regression test: test_staged_create_with_non_reusable_field_ids[stream=false/true] covers both staged entry points.

  • With the opt-in on WriteParams, staging fails with InvalidInput and no data/ directory is created.
  • Staging without it, then committing through CommitBuilder::new(uri).use_non_reusable_field_ids(true): reopening shows the high-water mark. Dropping b, the highest-ID column (ID 1), and adding c gives c the fresh ID 2.

cargo test -p lance --lib -- non_reusable: 18 passed.

I can't add labels from a fork, so could a maintainer add breaking-change, as the Gatekeeper asked? WriteParams gains a public enable_non_reusable_field_ids field.

@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Dec 1, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Dec 1, 2026
…on-reusable-field-ids

# Conflicts:
#	python/python/tests/test_dataset.py
#	rust/lance-table-runtime/src/write/insert.rs
A clone copies its source's manifest instead of building one, so the
activation set by use_non_reusable_field_ids never reached it: the clone
committed without the high-water mark or writer flag and reused field IDs.

Refuse the combination with InvalidInput before anything is written,
pointing to migrate_to_non_reusable_field_ids on the clone.
@vaibhavdabas16

Copy link
Copy Markdown
Contributor Author

Thanks for catching the clone path. Fixed in 9705cec.

A clone copies its source's manifest rather than building one, so ManifestBuildConfig activation can't reach it. Instead of letting the option be silently ignored, CommitBuilder now refuses use_non_reusable_field_ids(true) on an Operation::Clone commit with InvalidInput, before anything is written. The error says the clone keeps its source's field ID setting and points to migrate_to_non_reusable_field_ids on the clone. Both builders' docs say so too.

test_clone_rejects_non_reusable_field_ids[is_shallow=true/false] commits a shallow clone and a deep clone. The deep one sets with_deep_clone_files_copied() so it gets past the deep-clone check. Each test asserts the InvalidInput names use_non_reusable_field_ids and that no dataset was created at the destination.

I also merged main into the branch (2ea587b) to resolve the conflicts with the new write-stage instrumentation in InsertBuilder. The staged-create check is now passed through upstream's version of those functions.

cargo test -p lance --lib -- non_reusable clone_rejects: 29 passed. The breaking-change label is still needed, and I can't add it from a fork.

@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Dec 2, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Gate recommendation: approve.

Verified the author’s fix: clone commits now reject the opt-in explicitly, closing the remaining finding. Both staged creation paths retain their guards, and activation through the public commit builder preserves non-reusable field IDs.

Please mark this PR with the breaking-change label: lance::dataset::WriteParams and lance_table_runtime::write::WriteParams gain enable_non_reusable_field_ids, so Rust callers using exhaustive struct literals must initialize the new field.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Dec 2, 2026
@Xuanwo
Xuanwo merged commit 4ce9f51 into lance-format:main Dec 2, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-python Python bindings breaking-change enhancement New feature or request K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants