feat: support structured_query in the directory namespace query_table#7592
Open
hamersaw wants to merge 1 commit into
Open
feat: support structured_query in the directory namespace query_table#7592hamersaw wants to merge 1 commit into
hamersaw wants to merge 1 commit into
Conversation
The directory namespace's query_table only handled string_query; a structured_query was silently ignored, so the scan ran without any full-text filter and returned all rows. Map the namespace structured FtsQuery model into the engine FtsQuery for all variants — match, phrase, multi_match, and (recursively) boolean and boost — and run it via FullTextSearchQuery::new_query, mirroring the mapping the JNI scanner already performs. An FtsQuery with no variant set is now rejected rather than silently ignored. string_query behavior is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The directory namespace's
query_tableonly handledstring_queryfor full-text search — astructured_querywas silently ignored, so the scan ran with no FTS filter and returned all rows. This wiresstructured_querythrough to the engine, so the localquery_tablepath honors structured FTS the same way the JNI scanner andfragment.new_scan(full_text_query)already do. There was a literal// For now, we only support string_queryTODO at the change site.What changed
rust/lance-namespace-impls/src/dir.rs:structured_querybranch inquery_tablethat runsFullTextSearchQuery::new_query(...)built from the namespace model.build_engine_fts_querymapsmodels::FtsQuery→ engineFtsQueryfor all variants (match,phrase,multi_match, and recursivelyboolean/boost), mirroring the mapping inlance-jni/src/blocking_scanner.rs.build_engine_match_querycopiesterms/column/boost/fuzziness/max_expansions/operator/prefix_length, parsing the operator string viaOperator::try_from.FtsQuerywith no variant set is now rejected with a clear error instead of silently ignored.string_querybehavior is unchanged.Tests
Unit tests for the mapping —
test_build_engine_fts_query_match(allMatchQueryoptions round-trip into the engine query) andtest_build_engine_fts_query_requires_a_variant(empty query is rejected).cargo test -p lance-namespace-impls,cargo check -p lance-namespace-impls, andcargo fmt --checkall pass.Motivation
Downstream connectors (e.g. lance-spark) route full-text search to the namespace
query_tableand build the richerstructured_queryform (fuzziness / operator / phrase / multi_match). Against a directory namespace that droppedstructured_query, those queries silently returned every row instead of filtering. This makes thedirnamespace honor the structured API — which is the canonical FTS query direction (the engine'sFullTextSearchQueryis structured internally;string_queryis the legacy convenience form, and LanceDB's remote path already prefers structured).🤖 Generated with Claude Code