-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-39321][SQL] Refactor TryCast to use RuntimeReplaceable #36703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
d1695e6 to
58bf9dd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the fix.
|
@cloud-fan Could you resolve conflicts, please. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused. The default value of USER_SPECIFIED_CAST seems to be false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
USER_SPECIFIED_CAST is a TreeNodeTag that is only used by Cast, we don't need to set it in TryCast. Let me improve the comment.
gengliangwang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the refactoring!
|
thanks for the review, merging to master! |
### What changes were proposed in this pull request? For the following query ``` SET spark.sql.ansi.enabled=true; SELECT try_cast(1/0 AS string); ``` Spark 3.3 will throw an exception for the division by zero error. In the current master branch, it returns null after the refactoring PR #36703 This PR is to restore the previous error handling syntax. ### Why are the changes needed? 1. Restore the behavior of try_cast() 2. The previous syntax is more reasonable. Users can cleanly catch the exception from the child of `try_cast`. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Unit tests Closes #37486 from gengliangwang/restoreTryCast. Authored-by: Gengliang Wang <[email protected]> Signed-off-by: Gengliang Wang <[email protected]>
What changes were proposed in this pull request?
This PR refactors
TryCastto useRuntimeReplaceable, so that we don't needCastBaseanymore. The unit tests are also simplified because we don't need to check the execution ofRuntimeReplaceable, but only the analysis behavior.Why are the changes needed?
code cleanup
Does this PR introduce any user-facing change?
no
How was this patch tested?
existing tests