fix(optimizer): bound planning-time regex compilation - #24917
Open
goutamadwant wants to merge 1 commit into
Open
fix(optimizer): bound planning-time regex compilation#24917goutamadwant wants to merge 1 commit into
goutamadwant wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #24917 +/- ##
========================================
Coverage 81.62% 81.63%
========================================
Files 1123 1123
Lines 409637 410092 +455
Branches 409637 410092 +455
========================================
+ Hits 334383 334780 +397
- Misses 55624 55633 +9
- Partials 19630 19679 +49 ☔ View full report in Codecov by Harness. 🚀 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.
Which issue does this PR close?
Rationale for this change
Pathological constant regexes can spend the regex engine's full runtime compilation budget during constant folding, making logical planning take seconds. Disabling folding for every regex would also penalize ordinary patterns, so this change gives planning a smaller compilation budget and defers only expensive literals to execution.
What changes are included in this PR?
ScalarUDFImpl::should_evaluate_consthook so immutable UDFs can defer expensive literal evaluation in both logical and physical simplification.regexp_likeand regex operators while retaining the existing runtime limit.What is the testing strategy for this PR?
cargo test -p datafusion-expr -p datafusion-functions -p datafusion-optimizer -p datafusion-physical-exprcargo test -p datafusion expensive_regexp_like_is_deferred_to_execution --test core_integrationcargo test --profile=ci --test sqllogictests -- regexp/regexp_like.sltavro,json,backtrace,extended_tests,recursive_protection, andparquet_encryptionfeatures.Are there any user-facing changes?
Planning now defers unusually expensive constant regexes to execution instead of spending the runtime compilation budget while optimizing the query. Ordinary constant regexes continue to fold. This also adds a defaulted
ScalarUDFImpl::should_evaluate_constextension point; existing UDF implementations keep their current behavior.