Shekharrajak opened a new pull request, #3372:
URL: https://github.com/apache/datafusion-comet/pull/3372

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements and this helps us generate change logs for our releases. You can 
link an issue to this PR using the GitHub syntax. For example `Closes #123` 
indicates that this PR will close issue #123.
   -->
   
   Closes https://github.com/apache/datafusion-comet/issues/3345
   
   ## Rationale for this change
   
   When array_contains() is called with a literal cast(NULL as array<int>) 
argument, Comet returns a different result than Spark. Spark follows SQL        
 
     three-valued logic where array_contains(NULL, value) should return NULL, 
but Comet was delegating directly to DataFusion's array_has without proper NULL 
     array handling.                                                            
                                                                              
                                                                                
                                                                              
     Other array functions like CometArrayRemove and CometArrayAppend already 
handle NULL arrays correctly using a CASE WHEN wrapper, but CometArrayContains  
     was missing this handling.    
   
   ## What changes are included in this PR?
   
    - Added NULL array handling to CometArrayContains in arrays.scala by 
wrapping the array_has call in a CASE WHEN expression:                          
    
       - WHEN array IS NOT NULL THEN array_has(array, key)                      
                                                                              
       - ELSE NULL                                                              
                                                                              
     - This follows the same pattern used by CometArrayRemove and 
CometArrayAppend  
   
   ## How are these changes tested?
   
     Added new test "array_contains - NULL array returns NULL" in 
CometArrayExpressionSuite 
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to