Repository navigation
feat(index): configure JSON sub-document ingestion - #10563
wirybeaver wants to merge 1 commit into
Conversation
|
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: ❌ Blocked — 0 of 3 required approvals
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.
❌ Gate recommendation: request changes.
The configuration and persistence step fits the staged design in #7445. Keep flattened indexing unavailable at the index-build boundary until its write and query paths are connected; accepting the explicit mode now can silently omit every source row from the index.
| Some("json") => Ok(Box::new( | ||
| JsonTokenizer::new(tokenizer) | ||
| .with_mode( | ||
| self.json_tokenizer_mode |
There was a problem hiding this comment.
Selecting json_tokenizer_mode="flattened_sub_docs" through generic Rust/Java index parameters now successfully builds an empty index. InvertedIndexBuilder::process_document still calls token_stream_for_doc() and consumes it with advance(), which never checks the deferred “requires token_streams_for_doc” error. Consequently the build succeeds with no documents or tokens, and indexed searches lose all matches. Keeping the default unchanged does not protect callers who explicitly select the newly accepted mode. Reject this mode at index-build admission until the write/query stages are ready; persisting its metadata can remain separate from enabling ingestion.
Reproducer
I added this diagnostic test to the existing builder.rs test module and ran cargo test -p lance-index --lib gate_repro_json_mode_training --no-default-features. The single_document control passes; both with_position cases fail on flattened_sub_docs with num_docs: 0 and num_tokens: 0, after both update and reopen return success.
#[rstest::rstest]
#[tokio::test]
async fn gate_repro_json_mode_training(
#[values(false, true)] with_position: bool,
) -> Result<()> {
for mode in ["single_document", "flattened_sub_docs"] {
let store = Arc::new(LanceIndexStore::new(
ObjectStore::memory().into(),
Path::from("gate-json-mode"),
Arc::new(LanceCache::no_cache()),
));
let params = InvertedIndexParams::from_training_json(&format!(
r#"{{"json_tokenizer_mode":"{mode}","lance_tokenizer":"json","with_position":{with_position},"stem":false,"remove_stop_words":false,"num_workers":1}}"#,
))?;
let batch = make_doc_batch(r#"{"a":["hello","world"]}"#, 0);
let stream = RecordBatchStreamAdapter::new(batch.schema(), stream::iter(vec![Ok(batch)]));
InvertedIndexBuilder::new(params)
.update(Box::pin(stream), store.as_ref(), None)
.await?;
let index = InvertedIndex::load(store, None, &LanceCache::no_cache()).await?;
let statistics = index.statistics()?;
assert!(statistics["num_docs"].as_u64().unwrap() > 0,
"accepted mode {mode} silently wrote an empty index: {statistics}");
}
Ok(())
}
Motivation
JSON ingestion settings need to reach Rust from Python and Java and survive an index reopen. This completes the configuration layer in #7445, building on the JSON tokenizer.
Modification
Rust persists the tokenizer mode, sibling-array policy, and optional per-row limit with the index. Missing mode metadata still means
SingleDocument. Python and Java expose the ingestion controls through their existing index parameters; validation and tokenization behavior stay in Rust.A row above the limit either fails or is skipped in full, according to the selected policy. The new mode becomes the default after the write and query paths are connected.
Test
The existing Python JSON-index lifecycle test reads the configured sibling-array and row-limit policies back from the index details, exercising the binding, Rust parameters, and metadata together.