Add SEMANTIC_MATCH filter predicate for hidden semantic search layer#18191
Open
xiangfu0 wants to merge 1 commit intoapache:masterfrom
Open
Add SEMANTIC_MATCH filter predicate for hidden semantic search layer#18191xiangfu0 wants to merge 1 commit intoapache:masterfrom
xiangfu0 wants to merge 1 commit intoapache:masterfrom
Conversation
Registers SEMANTIC_MATCH(column, queryText, topK) as a Calcite SQL function and FilterKind so it can be parsed and passed through the query rewriter chain. The SemanticSearchQueryRewriter (in startree-pinot) translates it to VECTOR_SIMILARITY at query time after computing the embedding vector. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #18191 +/- ##
=============================================
- Coverage 63.13% 34.97% -28.16%
+ Complexity 1616 789 -827
=============================================
Files 3213 3229 +16
Lines 195730 196720 +990
Branches 30240 30414 +174
=============================================
- Hits 123569 68800 -54769
- Misses 62288 121855 +59567
+ Partials 9873 6065 -3808
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
SEMANTIC_MATCH(column, 'query text'[, topK])as a Calcite SQL function inPinotOperatorTableSEMANTIC_MATCHtoFilterKindenum so it flows through the standard predicate pipelineCalciteSqlParser.validateFilter(): requires 2–3 args, column identifier as first arg, non-null string literal as secondPredicateComparisonRewriterso the predicate is preserved for downstream rewritersThe intent is to support a hidden semantic search layer: a
SemanticSearchQueryRewriter(in the StarTree extension) interceptsSEMANTIC_MATCHat query time, computes the embedding vector for the query text, then rewrites the predicate toVECTOR_SIMILARITYbefore execution. This PR provides the OSS hook that makes that rewrite chain possible.Test plan
CalciteSqlParser,PredicateComparisonRewriter,FilterKindusagesSELECT ... FROM t WHERE SEMANTIC_MATCH(embedding_col, 'some query', 10)parses without error and round-trips through the rewriter chain unchangedIllegalStateExceptionat parse time🤖 Generated with Claude Code