[SPARK-47803][FOLLOWUP] Check nulls when casting nested type to variant. #46486
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
It adds null checks when accessing a nested element when casting a nested type to variant. It is necessary because the
get
API doesn't guarantee to return null when the slot is null. For example,ColumnarArray.get
may return the default value of a primitive type if the slot is null.Why are the changes needed?
It is a bug fix is necessary for the cast-to-variant expression to work correctly.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Two new unit tests. One directly uses
ColumnarArray
as the input of the cast. The other creates a real-world situation whereColumnarArray
is the input of the cast (scan). Both of them would fail without the code change in this PR.Was this patch authored or co-authored using generative AI tooling?
No.