dejankrak-db opened a new pull request, #56237:
URL: https://github.com/apache/spark/pull/56237

   ### What changes were proposed in this pull request?
   
   Add a `case (NullType, _)` handler in `ExtractValue.extractValue()` that 
returns `Literal(null, NullType)` instead of falling through to the 
`INVALID_EXTRACT_BASE_FIELD_TYPE` error. This aligns with standard SQL 
semantics where any operation on NULL yields NULL.
   
   ### Why are the changes needed?
   
   Extracting a field/element/key from a `NullType` base expression (which can 
occur when a column has `NullType`, e.g. from schema evolution with missing 
columns) previously threw an `INVALID_EXTRACT_BASE_FIELD_TYPE` analysis error. 
It should instead return NULL, consistent with NULL-propagation semantics.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. Queries that extract a struct field, array element, or map key from a 
`NullType` column now return NULL instead of failing with an 
`INVALID_EXTRACT_BASE_FIELD_TYPE` error. This also makes `isExtractable` return 
true for `NullType` attributes.
   
   ### How was this patch tested?
   
   Added a golden-file test `extract-value-nulltype` covering struct field 
access, array indexing, map key access, and a HAVING clause referencing a field 
of a `NullType` grouped column.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Yes, co-authored using Claude code.


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