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

   ## What is the purpose of the change    
                                                                                
                                                                     
   `REGEXP_REPLACE` declared its output via `nullableIfArgs`, so the planner 
inferred a `NOT NULL` result when all three arguments were `NOT NULL`. But the 
runtime returns `null` for a     
   non-literal regex that fails to compile: a column reference or a 
`CONCAT(...)` result is only validated at runtime, not at planning time. That 
let a `null` flow through a column the     
   planner believed was non-null, which is unsound.                             
                                                                                
                             
                                                                                
                                                                                
                             
   This is a sub-task of the FLINK-39648 umbrella.                              
                                                                                
                             
                                                                                
                                                                                
                             
   ## Brief change log 
                                                                                
                                                                                
         
   - Change `BuiltInFunctionDefinitions.REGEXP_REPLACE` output type strategy 
from `nullableIfArgs(explicit(STRING()))` to 
`explicit(DataTypes.STRING().nullable())`, matching                
   `REGEXP_EXTRACT`, which is always-nullable for the same reason. (`REGEXP` 
keeps `nullableIfArgs` because it returns `false`, not `null`, on an invalid 
pattern.)                          
                                                                                
                                                                                
                             
   ## Verifying this change                                                   
                                                                                
                                  
   This change added a test and can be verified as follows:                     
                                                                                
                             
   - New `RegexpFunctionsITCase` case with `NOT NULL` arguments and a 
non-literal invalid regex, asserting the output type stays nullable and the 
value is `null`.                           
   - Existing `RegexpFunctionsITCase`, `ScalarFunctionsTest`, 
`SqlExpressionTest`, `MultiJoinTest` (plan digests unchanged), and 
`ExpressionSerializationTest` regress the function.         
                                                                                
                                                                                
                             
   ## 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): no              
                                                                                
                             
   - 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