raminqaf opened a new pull request, #28292:
URL: https://github.com/apache/flink/pull/28292

   ## What is the purpose of the change      
                                                                                
                                                                                
                                                                                
                                                                                
                                                      
   `REGEXP` does not validate literal regex patterns at planning time. When the 
regex is a string literal that fails `Pattern.compile`, the predicate logged an 
`ERROR` stack trace per record on the hot path (for example `... WHERE payload 
REGEXP '('`). This PR surfaces the failure as a `ValidationException` during 
type inference and removes the per-record log spam.                             
                    
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                
   This is a sub-task of the FLINK-39648 umbrella, following the pattern 
already established for `REGEXP_EXTRACT` (FLINK-39649) and `REGEXP_REPLACE` 
(FLINK-39650). It reuses the shared `StrategyUtils.validateLiteralPattern` 
helper introduced by those sub-tasks.                                           
                                                                                
                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                
   ## Brief change log                                                          
                                                                                
                                                                                
                                                                                
                                                                                
                
   - Drop the hot-path `LOG.error` in `SqlFunctionUtils.regExp`; catch 
`PatternSyntaxException` and return false. The pattern was already looked up 
through `REGEXP_PATTERN_CACHE`.                                                 
                                                                                
                                                                                
                            
   - Migrate `BuiltInFunctionDefinitions.REGEXP` to `name("REGEXP")` + 
`runtimeProvided()`. Remove the legacy `FlinkSqlOperatorTable.REGEXP` entry, 
the `DirectConvertRule` mapping, and the `case REGEXP` arm in `StringCallGen`. 
Add a routing arm in `ExprCodeGenerator`'s `BridgingSqlFunction` block.         
                                                                                
                             
   - Add `RegexpInputTypeStrategy` that validates 2 STRING args and the literal 
regex via `StrategyUtils.validateLiteralPattern`. Wire it through 
`SpecificInputTypeStrategies.REGEXP`.                                           
                                                                                
                                                                                
                              
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                
   ## Verifying this change                                                     
                                                                                
                                                                                
                                                                                
                                                                                
                
   This change added tests and can be verified as follows:                      
                                                                                
                                                                                
                                                                                
                                                                                
                
   - New `RegexpInputTypeStrategyTest` covers four branches: non-literal regex 
defers, valid literal compiles, null literal is deferred, invalid literal fails 
at plan time.                                                                   
                                                                                
                                                                                
                 
   - New `regexpTestCases()` in `RegexpFunctionsITCase` covers runtime behavior 
end-to-end (literal match/no-match, null input, column-ref invalid, 
function-call regex) plus a plan-time validation case via Table API and SQL.    
                                                                                
                                                                                
                            
   - Existing `ScalarFunctionsTest`, `AsyncCalcSplitRuleTest`, and 
`AsyncCalcITCase` regress the operator.                                         
                                                                                
                                                                                
                                                                                
                             
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                
   ## Does this pull request potentially affect one of the following parts:     
                                                                                
                                                                                
                                                                                
                                                                                
                
   - Dependencies (does it add or upgrade a dependency): no                     
                                                                                
                                                                                
                                                                                
                                                                                
                
   - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: no                                                         
                                                                                
                                                                                
                                                                                
                                 
   - The serializers: no                                                        
                                                                                
                                                                                
                                                                                
                                                                                
                
   - The runtime per-record code paths (performance sensitive): yes (removes 
per-record `LOG.error` in `regExp` on invalid patterns)                         
                                                                                
                                                                                
                                                                                
                   
   - Anything that affects deployment or recovery: no                           
                                                                                
                                                                                
                                                                                
                                                                                
                
   - The S3 file system connector: no                                           
                                                                                
                                                                                
                                                                                
                                                                                
                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                
   ## Documentation                                                             
                                                                                
                                                                                
                                                                                
                                                                                
                
   - Does this pull request introduce a new feature? no                         
                                                                                
                                                                                
                                                                                
                                                                                
                
   - If yes, how is the feature documented? not applicable                      
                                                                                
                                                                                
                                                                                
                                                                                
                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                
   ---                                                                          
                                                                                
                                                                                
                                                                                
                                                                                
                
   ##### Was generative AI tooling used to co-author this PR?                   
                                                                                
                                                                                
                                                                                
                                                                                
                
   - [x] Yes (please specify the tool below)
     
   Generated-by: Opus 4.8                                                       
                                                                                
                                                                                
                                                                                
                                                                                
                


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to