Repository navigation
Conversation
Dataset::migrate_to_non_reusable_field_ids had no binding, so only Rust callers could stop field IDs from being reused after a column is dropped. Add LanceDataset.migrate_to_non_reusable_field_ids() and Dataset.migrateToNonReusableFieldIds(), mirroring the existing manifest path migration bindings. Part of lance-format#10684.
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The bindings reuse the existing Rust migration without introducing a second allocation path. Local Python and Java tests passed, including idempotency, persisted field IDs, and a three-fragment check of data preservation and stale-handle failure handling.
Xuanwo
left a comment
There was a problem hiding this comment.
Both bindings call the existing Rust migration and document the writer feature-flag requirement. With the Python extension built from d4445549, all eight rows across four fragments remained readable after migration, drop/add, append and reopen. Field IDs advanced through 3 without reuse. Repeating the migration on a fresh handle added no version, and a stale migration failed without changing its handle. JNI Rust clippy passed locally. Hosted Java 17 ran all 83 DatasetTest cases with no failures or skips, and the Java 11, 21 and 25 jobs also passed.
Keep both migration APIs and Java base registration. Align documentation with the Rust high-water mark and verify the Java dataset version before and after repeated activation.
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:** - `cargo test -p lance --lib -- non_reusable`: 18 passed. - `cargo check` passes for `python/`. - cargo fmt, ruff and ruff-format pass. - I couldn't run the Python test locally because there's no maturin build on my machine. The docstring links to `migrate_to_non_reusable_field_ids`, which #11472 adds.
Part of #10684 (item 1: Python and Java bindings for
migrate_to_non_reusable_field_ids).Dataset::migrate_to_non_reusable_field_idshad no binding, so only Rust callers could stop field IDs from being reused after a column is dropped. This adds:LanceDataset.migrate_to_non_reusable_field_ids(), plus the.pyistub.Dataset.migrateToNonReusableFieldIds(), plus its JNI function. It takes the dataset write lock, likemigrateManifestPathsV2.Both mirror the existing manifest path migration bindings. The docs repeat the Rust method's warning: every client that writes to the dataset must enforce writer feature flags before the migration runs.
Item 2 of the issue, a create-time option such as
WriteParams::enable_non_reusable_field_ids, changesWriteParams, so I'm leaving it for a separate PR.Tests: both reproduce the example from the issue.
test_migrate_to_non_reusable_field_ids[False/True]. It addsb, optionally migrates (checking that a second call is a no-op), dropsband addsc. Without the migrationcreusesb's ID 1; with it,cgets ID 2.DatasetTest.testMigrateToNonReusableFieldIdscovers the same sequence. After migrating, the re-added column gets ID 3 instead ofdouble_id's dropped ID 2.Checks run locally:
cargo checkpasses forpython/and forjava/lance-jni.