[SPARK-46448][SQL] InlineTable column should be nullable when converted to Decimal might cause null#44404
Closed
amaliujia wants to merge 4 commits intoapache:masterfrom
Closed
[SPARK-46448][SQL] InlineTable column should be nullable when converted to Decimal might cause null#44404amaliujia wants to merge 4 commits intoapache:masterfrom
amaliujia wants to merge 4 commits intoapache:masterfrom
Conversation
… Decimal might cause null.
Contributor
Author
Contributor
|
Can you fully fill the PR description? |
Contributor
Author
|
@cloud-fan my bad. The save button didn't work on my previous edit. |
cloud-fan
reviewed
Dec 19, 2023
| } | ||
|
|
||
| test("SPARK-46448: InlineTable column is nullable if converting to Decimal could be null") { | ||
| val plan = sql("SELECT * FROM values(-0.172787979),(533704665545018957788294905796.5)") |
Contributor
There was a problem hiding this comment.
wait, so we still get null value at the end?
Contributor
Author
There was a problem hiding this comment.
This is only a defensive change because Cast.canNullSafeCastToDecimal(t, d) still has code to return false. though we know that no null value will happen at the end.
Contributor
Author
|
Closing this PR for now as this may not be needed given that the real value will not be null. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?
InlineTable column can also be nullable when there is type conversion to Decimal and it is not safe to be converted to null. So this PR updates the column nullability to true when there is type conversion to Decimal and the conversion is safe to make the new type null.
Note that given current implementation for conversion to Decimal, it is not likely null will happen, however because
canNullSafeCastToDecimalstill could return false so we need a defensive check for that case.Why are the changes needed?
This is to make the nullability behavior consistent after type conversion in InlineTable.
Does this PR introduce any user-facing change?
NO
How was this patch tested?
UT
Was this patch authored or co-authored using generative AI tooling?
NO