feat(index): support Utf8View patterns in the ngram TextQueryParser#7310
Open
wombatu-kun wants to merge 2 commits into
Open
feat(index): support Utf8View patterns in the ngram TextQueryParser#7310wombatu-kun wants to merge 2 commits into
wombatu-kun wants to merge 2 commits into
Conversation
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.
Follow-up to #7139.
Problem
The ngram
TextQueryParserextracts string patterns and regex flags by matching onlyScalarValue::Utf8andScalarValue::LargeUtf8. When the indexed column isUtf8View,safe_coerce_scalar(rust/lance-datafusion/src/expr.rs) coerces the predicate literal toScalarValue::Utf8View(Some(..)), which the parser then fails to match. As a result an ngram index on aUtf8Viewcolumn silently does not acceleratecontains,regexp_like, or infixLIKE; they fall back to a full scan.Change
Add the
Utf8Viewarm to all three string-extraction sites inTextQueryParser: thecontains/regexp_likepattern invisit_scalar_function, the infix-LIKE pattern invisit_like, and the regex-flags literal inapply_regex_flags. The bindings are unchanged because all three stringScalarValuevariants carry anOption<String>.Tests
test_text_query_parser_utf8view: assertscontainsandregexp_likeover aUtf8View-typed ngram index route to the index (StringContains/Regexqueries), and that infixLIKEwith aUtf8Viewpattern is accelerated, with aUtf8parity control.test_apply_regex_flagswith aUtf8Viewflags literal.Each test fails on the pre-change code and passes after.
Out of scope
The identical pre-existing gap in
SargableQueryParser(starts_with/ LIKE-prefix) is left untouched - it is a separate feature that #7139 never modified, so folding it in would be unrelated scope. It can be a separate change if desired.This addresses the non-blocking review comment #7139 (comment) from @wjones127.