Repository navigation
[GLUTEN-13476][VL] Fall back regex patterns with character class intersection - #13477
Merged
Merged
Conversation
Contributor
Author
|
@philo-he Could you take a look? It's in the re2 regex validation. |
Contributor
Author
|
Thank you @philo-he |
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.
What changes are proposed in this pull request?
Java's
java.util.regexreads&&inside a character class as set intersection, while RE2 reads it as two literal&characters.ensureRegexIsCompatiblealready rejects nested classes such as[a[b]]and[a&&[b]], but the bare form[a&&b]passes, so the native function returns a different result than vanilla Spark. For example,'a' RLIKE '[a&&d]'is true in Gluten and false in vanilla Spark.This rejects
&&inside a character class, so the expression falls back.&&outside a class and an escaped\&are still accepted, since both engines read them the same way.It also fixes the class tracking for a
]right after[^. Java and RE2 both read that]as a class member, but the check ended the class there, so[^]&&x]and[^][a]]passed it. Now]right after[or[^keeps the class open.The Bolt copy of
ensureRegexIsCompatiblegets the same change.Fixes #13476.
How was this patch tested?
Added
regex with character class intersection falls backtoVeloxStringFunctionsSuite. It runsrlikewith[a&&d],regexp_extractwith[a-z&&l-p]andregexp_replacewith[^]&&x], compares each result with vanilla Spark and checks that the fallback reason mentions the character class. It also checks that[a&d]with a single&still runs natively. Without this change the test fails on[a&&d]. With only the&&check and not the[^]fix it fails on[^]&&x].The Bolt change is not compiled or tested by CI.
Was this patch authored or co-authored using generative AI tooling?
Yes. Generated-by: Claude Opus.