Fix flaky AND-only MATCH queries#111
Open
SnobbyDragon wants to merge 1 commit into
Open
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
ramtinb
approved these changes
Jun 9, 2026
MeghaS14
added a commit
that referenced
this pull request
Jun 12, 2026
Product (cc @Angela Li): - StarRocks StarRocks#73168: OR+MATCH GIN fallback refactor (OrMatchFallbackVisitor, rowid buffer reuse, _wrap_or_match_predicates_for_fallback, tests). - pinterest #108: partial update on GIN tables (SegmentFileMark + SQL test). - pinterest #111: guard empty scan range before predicate rewrite. - StarRocks StarRocks#68311: base OR+MATCH inverted-index fallback (StarRocks#73168 builds on). Build / 4.1 pipeline: - Thrift 0.23 (thirdparty/vars.sh, Java libthrift) for dev-env-ubuntu:4.1-latest. - BE thrift_util: TOutput::instance() for Thrift 0.23. - Java deps aligned with 4.1.0-rc01: AWS 2.29.52, Hadoop 3.4.1, Netty 4.1.128.Final; FE and common-runtime use AWS bundle only for consistent fe/lib. - trivy.yaml: Hadoop jar pin for scans. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Why I'm doing:
Starrocks would sometimes return
Match can only used as a pushdown predicate on column with GIN in a single query.error for valid AND-only MATCH queries. The same query would also sometimes succeed.This flaky behaviour was due to the error only occurring when a segment was empty (either initialized empty or after being pruned by ranges/bitmap/indices/sampling/etc.)
If the segment was empty, we would skip deleting the MATCH predicate during
_apply_inverted_indexand proceed to_rewrite_predicates, which would then see the MATCH predicate and cause the error.What I'm doing:
Check if the segment is empty before attempting rewriting the predicates.
If the segment is empty, we don't need to rewrite because there are no rows anyways.
With this fix, it is possible that an invalid MATCH query would return 0 rows instead of raising an error.
This case would be very rare because it would require all segments to be empty after pruning, so we would never attempt predicate rewriting + raise the MATCH error. We can fix this issue in a later PR-- this current issue that has errors for valid queries is a bigger problem.
Test Plan
https://docs.google.com/document/d/14Sh09fW9gxYKOUcFi6ZnjlovPv4D5PZRV5fvr82iEuw/edit?usp=sharing
Manual testing w/ test cases ^
Inverted index integration tests pass locally (except for the one that requires multiple hosts-- this is expected to fail locally)
test_scan also succeeds
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check: