spark icon indicating copy to clipboard operation
spark copied to clipboard

[SPARK-49768][SQL] Provide error conditions for `make_date`/`make_timestamp` errors `_LEGACY_ERROR_TEMP_2000`

Open itholic opened this issue 1 year ago • 4 comments

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

itholic avatar Sep 25 '24 10:09 itholic

cc @srielau @cloud-fan

itholic avatar Sep 25 '24 10:09 itholic

Thanks @srielau for the review! Just adjusted the comments :)

itholic avatar Sep 26 '24 00:09 itholic

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 avatar Oct 03 '24 03:10 itholic

@itholic please update description of the PR to follow the changes added.

mihailom-db avatar Oct 06 '24 14:10 mihailom-db

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!

github-actions[bot] avatar Jan 17 '25 00:01 github-actions[bot]