spark
spark copied to clipboard
[SPARK-49768][SQL] Provide error conditions for `make_date`/`make_timestamp` errors `_LEGACY_ERROR_TEMP_2000`
What changes were proposed in this pull request?
This PR proposes to provide proper error conditions for _LEGACY_ERROR_TEMP_2000 and improve the error message
Why are the changes needed?
To provide better user-facing error message
Does this PR introduce any user-facing change?
No API changes, but the user-facing error message will be improved:
Before
>>> spark.sql("SELECT make_date(2024, 13, 1);").show()
Invalid value for MonthOfYear (valid values 1 - 12): 13. If necessary set "spark.sql.ansi.enabled" to false to bypass this error.
After
>>> spark.sql("SELECT make_date(2024, 13, 1);").show()
[DATE_TIME_FIELD_OUT_OF_BOUNDS] Invalid value for datetime field. If necessary set "spark.sql.ansi.enabled" to false to bypass this error. SQLSTATE: 22008
How was this patch tested?
The existing SQL tests should pass
Was this patch authored or co-authored using generative AI tooling?
No
cc @srielau @cloud-fan
Thanks @srielau for the review! Just adjusted the comments :)
Please do not inherit SecondOfMinute etc... produce your own ranges so we can use '...' which is more readable that the '-' which reads like arithmetric. Something odd about that Feb 30 error. Clearly that is not an internal error.
@srielau applied the comments. Thanks for the review!
@itholic please update description of the PR to follow the changes added.
We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable. If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!