Skip to content

feat(index): configure JSON sub-document ingestion - #10563

Open
wirybeaver wants to merge 1 commit into
lance-format:mainfrom
wirybeaver:json-ingestion-config
Open

wirybeaver wants to merge 1 commit into
lance-format:mainfrom
wirybeaver:json-ingestion-config

Conversation

@wirybeaver

Copy link
Copy Markdown
Contributor

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.

Python / Java options
         |
Rust index parameters -------> JSON tokenizer
         |
persisted index details
         |
reopen / rebuild with the same settings

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.

@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 A-index Vector index, linalg, tokenizer A-java Java bindings + JNI A-format On-disk format: protos and format spec docs format-change A change to the format spec, which requires a vote. Remove if minor (e.g. fixing typo). enhancement New feature or request labels Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Important

Format specification vote

This 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

Approvals none (0/3)
Latest commit approved by none — one PMC member must approve the latest commit
Vetoes none
Voting period elapsed — ended Thu 2026-11-05 00:00 UTC (Wed 16:00 PST)

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 format-waived label to waive the vote for a trivial edit (typo, wording, formatting).

@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: 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

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.

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(())
    }

@lance-gatekeeper lance-gatekeeper Bot added K-changes Latest Gatekeeper recommendation requests changes. and removed K-changes Latest Gatekeeper recommendation requests changes. labels Nov 1, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-format On-disk format: protos and format spec docs A-index Vector index, linalg, tokenizer A-java Java bindings + JNI A-python Python bindings enhancement New feature or request format-change A change to the format spec, which requires a vote. Remove if minor (e.g. fixing typo). K-changes Latest Gatekeeper recommendation requests changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant