[SPARK-54836][SQL] Include timestamp value in ArithmeticException for timestamp overflow errors #53597
+29
−6
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?
Enhanced
timestampAddIntervalinDateTimeUtilsto catchArithmeticExceptionduring timestamp overflow and re-throw with contextual information including the input timestamp value and interval parameters.Why are the changes needed?
When users encounter timestamp overflow errors, the current generic "long overflow" message provides no context about which timestamp values caused the issue. This makes debugging difficult, especially in production environments with large datasets.
Example Error Message Improvement
Before:
java.lang.ArithmeticException: long overflow
After:
java.lang.ArithmeticException: long overflow. Input timestamp: 2262-04-11T23:47:16.854775807Z, interval: months=0, days=2, microseconds=0, zoneId=Z
Does this PR introduce any user-facing change?
Yes - users will see enhanced error messages with timestamp and interval details when overflow occurs.
How was this patch tested?
DateTimeUtilsSuite:timestamp add interval overflow with error messageLong.MaxValue, triggers overflow, and verifies error message contains contextual informationWas this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Sonnet 4.5