zhengruifeng opened a new pull request, #48410:
URL: https://github.com/apache/spark/pull/48410

   ### What changes were proposed in this pull request?
   Fix `containsNull` of `ArrayCompact`, by adding a new expression 
`KnownNotContainsNull`
   
   
   ### Why are the changes needed?
   
   https://github.com/apache/spark/pull/47430 attempted to set `containsNull = 
false` for `ArrayCompact` for further optimization, but in an incorrect way:
   
   The `ArrayCompact` is a runtime replaceable expression, so will be replaced 
in optimizer, and cause the `containsNull` be reverted, e.g.
   
   ```sql
   select array_compact(array(1, null))
   ```
   
   Rule `ReplaceExpressions` changed `containsNull: false -> true`
   ```
   old schema:
   StructField(map_from_entries(array_compact(array(struct(1, 1), 
NULL))),MapType(IntegerType,IntegerType,false),false)
   
   new schema
   StructField(map_from_entries(array_compact(array(struct(1, 1), 
NULL))),MapType(IntegerType,IntegerType,false),true)
   ```
   
   This may cause unexpected behavior in optimizer.
   
   
   ### Does this PR introduce _any_ user-facing change?
   no
   
   
   ### How was this patch tested?
   added tests
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   no


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