perf: Optimize regexp match and not match for .*foo.* cases#20610
Draft
petern48 wants to merge 14 commits intoapache:mainfrom
Draft
perf: Optimize regexp match and not match for .*foo.* cases#20610petern48 wants to merge 14 commits intoapache:mainfrom
.*foo.* cases#20610petern48 wants to merge 14 commits intoapache:mainfrom
Conversation
…(utf8view and largeutf8 support)
…ition (fixes old behavior)
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.
Which issue does this PR close?
.*foo.*#20579Rationale for this change
Improved query performance by optimizing logical plan
What changes are included in this PR?
Added optimization rules to perform the following logic
s ~ '.*foo.*'->contains(s, foo)s !~ '.*foo.*'->not(contains(s, foo))s ~ '.*.*'->is_not_null(s)s !~ '.*.*'->falseAdditionally, I found that the existing optimization for
s !~ .*was incorrectly converting the condition tos = '', which would return True for rows whereswas empty string (''). I confirmed this is different from default non-optimized query, which returns no rows even if some are empty string orNULL.The reasoning behind it always returning
Falseis that.*matches the empty string so not match should not include it. Additionally,NULLaren't returned either becauseNULL !'.*results inNULL`, not True. Therefore this condition is always False.Are these changes tested?
Added tests and updated existing tests to pass after fixing the bug in the pre-existing optimization.
Are there any user-facing changes?
This is a slight behavior change due to fixing a bug in the pre-existing optimization. Previously,
s !~ '.*'would return rows whereswas empty string. This PR fixes the bug so that no rows are returned, which matches the behavior when no optimizations are applied.