Repository navigation
fix(index): record the JSON wrapper's target index version - #9721
Conversation
There was a problem hiding this comment.
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.
Tip: disable this comment in your organization's Code Review settings.
|
Important Format specification voteThis PR modifies the Lance format specification, so it requires 3 binding +1 votes from PMC members (excluding the proposer), at least one of them on the latest commit, and a minimum 72-hour voting period, weekends excluded, before it can merge. Vote by approving this PR (+1) or requesting changes (−1, a veto). See the voting process. Approvals carry over across pushes, so a rebase or a typo fix does not send everyone back to re-vote. Whoever approves the latest commit is vouching that nothing substantive has changed since the earlier approvals; if something has, ask for fresh votes. Status: ✅ Vote passed — 3 PMC approvals, voting period elapsed
Updated automatically by the format-spec vote gate, which re-checks every 15 minutes — just voted? Re-check now (press Run workflow; leave the input blank to re-check every open format PR). A PMC member may apply the |
There was a problem hiding this comment.
Recording the target’s persisted version is the right fix for newly written JSON indices. Historical metadata still needs version inference when a target format changes; land this plumbing before the format-aware BTree reader in #9481, and handle that legacy ambiguity with the format transition.
Please mark this PR with the breaking-change label.
| // always came from a fresh training pass in the same codebase. | ||
| let target_index_version = json_details | ||
| .target_index_version | ||
| .unwrap_or_else(|| target_plugin.version()); |
There was a problem hiding this comment.
Older JSON/BTree indices still take the reader’s current maximum here, although their targets were written as V0. After the BTree version becomes V1, this branch will pass V1 for those V0 targets. Fresh training established the writer’s version; it does not establish the version of a later reader.
This preserves existing behavior and is non-blocking on this head because the current BTree loader ignores the argument. When #9481 begins using it to select the row-identifier domain, the transition needs historical target-version inference, such as V0 for pre-field BTree targets, or an authoritative marker in the target’s stored metadata.
A loader probe through this head’s JSON wrapper, including protobuf serialization, confirmed Some(0) → 0, Some(3) → 3, and None → 7 when the target plugin advertised version 7. This verifies the fallback selection; wrong-result behavior after the separate BTree transition was not tested here.
There was a problem hiding this comment.
Updating the context after the rebase: #9481 has merged, so BTree now uses this argument. A current-head probe through the JSON wrapper loaded the target in row-ID domain for Some(0), and address domain for both Some(1) and None. The absent-field fallback is identical in the base revision, so this remains pre-existing behavior.
The same probe verified that training, update, and both remap APIs persist the target's returned version, including zero. #9856 contains the broader historical inference and wrapper-domain migration; the stable-row-ID creation restriction remains unchanged here. This remains a non-blocking legacy risk for this plumbing change.
The gatekeeper review flagged that the row-address-domain migration isn't safe yet for a BTREE index wrapped in a JSON index: JsonIndexDetails has no field for the target's persisted version (load_index stands in with the target plugin's current max version instead), and the domain-safety checks protecting a plain BTree segment during merge/ compaction (IndexMetadata::results_are_row_addrs, append.rs's legacy_domain_mismatch) key off the outer index's own type_url, which a JSON wrapper's details never match. A wrapped BTREE segment that genuinely stored row addresses on a stable-row-id dataset would be invisible to all of that machinery. Rather than implement the full fix (threading the target's domain through the wrapper's own metadata -- #9721), reject the combination outright, at both write paths: fresh creation/rebuild (build_scalar_index) and incremental merge during optimize (merge_scalar_indices), before either does any work. A dataset without stable row ids is unaffected, since there a row id and a row address are the same value, so a plain BTREE index and a JSON-wrapped one created today keep working exactly as before. Co-Authored-By: Claude Sonnet 5 <[email protected]>
The gatekeeper review flagged that the row-address-domain migration isn't safe yet for a BTREE index wrapped in a JSON index: JsonIndexDetails has no field for the target's persisted version (load_index stands in with the target plugin's current max version instead), and the domain-safety checks protecting a plain BTree segment during merge/ compaction (IndexMetadata::results_are_row_addrs, append.rs's legacy_domain_mismatch) key off the outer index's own type_url, which a JSON wrapper's details never match. A wrapped BTREE segment that genuinely stored row addresses on a stable-row-id dataset would be invisible to all of that machinery. Rather than implement the full fix (threading the target's domain through the wrapper's own metadata -- #9721), reject the combination outright, at both write paths: fresh creation/rebuild (build_scalar_index) and incremental merge during optimize (merge_scalar_indices), before either does any work. A dataset without stable row ids is unaffected, since there a row id and a row address are the same value, so a plain BTREE index and a JSON-wrapped one created today keep working exactly as before. Co-Authored-By: Claude Sonnet 5 <[email protected]>
The gatekeeper review flagged that the row-address-domain migration isn't safe yet for a BTREE index wrapped in a JSON index: JsonIndexDetails has no field for the target's persisted version (load_index stands in with the target plugin's current max version instead), and the domain-safety checks protecting a plain BTree segment during merge/ compaction (IndexMetadata::results_are_row_addrs, append.rs's legacy_domain_mismatch) key off the outer index's own type_url, which a JSON wrapper's details never match. A wrapped BTREE segment that genuinely stored row addresses on a stable-row-id dataset would be invisible to all of that machinery. Rather than implement the full fix (threading the target's domain through the wrapper's own metadata -- #9721), reject the combination outright, at both write paths: fresh creation/rebuild (build_scalar_index) and incremental merge during optimize (merge_scalar_indices), before either does any work. A dataset without stable row ids is unaffected, since there a row id and a row address are the same value, so a plain BTREE index and a JSON-wrapped one created today keep working exactly as before. Co-Authored-By: Claude Sonnet 5 <[email protected]>
f424ab6 to
4bb84cd
Compare
|
Blocking: the absent-field fallback still uses the running plugin's current version, not the legacy file's version. For a concrete example:
Being freshly trained by the writer at the time does not mean the files match the reader's current version after an upgrade. This fallback pre-exists, but adding the field for new writes does not fix the legacy case. Could we use documented, evidence-backed legacy versions per target when the field is absent, and treat an unresolvable target as unsupported rather than guessing? The proto comment should describe that same rule. A regression where the historical target version is 0 but the plugin now supports 1 would cover this. |
There was a problem hiding this comment.
The 13.0.0 example is correct: those JSON details omit the target version, so the fallback passes V1 for a BTree target written as V0. The proto's “fresh training” explanation does not establish the version for an upgraded reader.
The recommendation remains non-blocking because the base already passes the same version for the same metadata; this patch leaves that legacy read path unchanged. #9856 includes historical-version inference and the wrapper-domain migration. This version-recording plumbing can land independently while retaining the stable-row-ID creation restriction.
Please mark this PR with the breaking-change label.
JsonIndexPlugin::load_index passed the target plugin's current max version instead of the version the target was actually persisted at, since JsonIndexDetails didn't record it. Store it from CreatedIndex::index_version on train/remap/update and use it on load, falling back to the plugin's current version for older details that predate this field. Co-Authored-By: Claude Sonnet 5 <[email protected]>
4bb84cd to
1f9d2f5
Compare
I've changed the fallback from "current version" to "old version" |
…rsion BasicTrainer::train_index for these three builtins always reports the current (address-domain) version: that generic path has no dataset awareness to tell whether a row id and a row address coincide, unlike build_scalar_index in the lance crate, which downgrades to the row-id-domain version for exactly that reason. The JSON wrapper now persists the target's trained index_version verbatim, so it picked up this always-address-domain value and failed test_json_wrapped_target_loads_as_row_id_domain on every platform. A JSON-wrapped target of these three types is never built on a stable-row-id dataset, so a row id and a row address always coincide here and the row-id-domain version is always correct. Share the floor-version lookup between load_index (fallback for details predating target_index_version) and train_index (override after training). Co-Authored-By: Claude Sonnet 5 <[email protected]>
Record the trained JSON target type in `JsonIndexDetails` and carry the raw recorded value through load, remap, update, and rebuild without retraining. Preserve the target index version from #9721, keep creation scalar-only, and retain the established PascalCase `JsonIndexParameters` spelling for recovery and rebuild compatibility. The new `details_as_json` field uses lowercase independently; `LargeBinary` remains legacy-only. Closes #9256.
Similar to #9814 (Bitmap/LabelList → row-address domain), and #9481 (BTree). It applies the same migration to the JSON index. JSON is a wrapper, so it takes its domain from the target index it wraps. This is also built on #9721 which adds the target index version to the JSON index details. Prior to this change we only supported creating JSON indexes against targets that were in their "legacy domain". For example, a JSON->BTREE index would be row ids and a JSON->ZONE_MAP index would be row addrs. This remains the behavior for JSON index version 0. This PR adds a new JSON index version (1) which can only be used with row address domain indcies. The new index version is really just simplification and convenience as it makes it easy to tell we are in the row address domain without consulting the index details and doing some complicated type-dependent logic (we could otherwise determine this from the target version and index type). However, it is also consistent with the other indexes which have been bumping the index version as part of the switch. The actual index itself did not need to change (it's just a wrapper) but some of the index management logic did (since JSON indexes could now potentially be row address indexes). --------- Co-authored-by: Claude Sonnet 5 <[email protected]>
Summary
JsonIndexPlugin::load_indexpassedtarget_plugin.version()(the target plugin's current max format version) instead of the version the target index was actually persisted at, sinceJsonIndexDetailsnever recorded it.target_index_versionfield (field 4) toJsonIndexDetails, populated fromCreatedIndex::index_versionwhenever the wrapper trains, remaps, or updates its target.load_indexnow reads it, falling back to the target plugin's current version only for details written before this field existed (matching the previous, safe-for-now behavior for old data).target_data_typedocs saying these details do not record the target's format version.Test plan
cargo clippy -p lance-index -p lance --tests -- -D warningscleancargo fmt --all -- --checkcleancargo test -p lance-index --lib scalar::json::— 27 passed🤖 Generated with Claude Code
https://claude.ai/code/session_018BsnoP9ZPMX6vhJSygzdnN