[SPARK-56915][SQL] Simplify MakeDate/MakeInterval codegen under ANSI mode#55940
Open
gengliangwang wants to merge 1 commit into
Open
[SPARK-56915][SQL] Simplify MakeDate/MakeInterval codegen under ANSI mode#55940gengliangwang wants to merge 1 commit into
gengliangwang wants to merge 1 commit into
Conversation
…mode ### What changes were proposed in this pull request? Introduce `DateTimeConstructorUtils.java` with two static helpers: * `makeDateExact(int year, int month, int day)`: wraps `LocalDate.of(...) + DateTimeUtils.localDateToDays(...)` in the `ansiDateTimeArgumentOutOfRange(DateTimeException)` try/catch. * `makeIntervalExact(int years, int months, int weeks, int days, int hours, int mins, Decimal secs)`: wraps `IntervalUtils.makeInterval` in the `arithmeticOverflowError(message, "", null)` try/catch. `datetimeExpressions.MakeDate` and `intervalExpressions.MakeInterval` delegate to the helpers in their `failOnError = true` codegen + eval paths. The non-ANSI branch keeps the inline `try/catch -> null` form because it sets `isNull = true` on failure. ### Why are the changes needed? Part of SPARK-56908 (umbrella). The 7-line try/catch wrapper that maps `DateTimeException` / `ArithmeticException` to the user-facing ANSI error was emitted inline in `doGenCode`; the helper collapses it to a single call per call site without losing the wrapped exception's message (no `QueryContext` argument is involved, so this PR introduces no per-row `references[]` regression). ### Does this PR introduce _any_ user-facing change? No. The compiled behavior is identical; only the emitted Java source text changes. ### How was this patch tested? ``` build/sbt "catalyst/testOnly *DateExpressionsSuite *IntervalExpressionsSuite" ``` 96/96 pass. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Cursor 1.x
This was referenced May 17, 2026
Member
Author
Stack overview (SPARK-56908 umbrella)This PR is part of a stack of 8 PRs against SPARK-56908. Order:
PRs 1-4 are linearly stacked on each other (each branch is based on the previous one). PR 5 (decimal arithmetic) is stacked on top of PR 3 (cast decimal) since it uses |
This was referenced May 17, 2026
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.
Title: [SPARK-56915][SQL] Refactor MakeDate/MakeInterval codegen under ANSI mode
Base: master (independent)
Head: gengliangwang:SPARK-56915-make-date-interval
What changes were proposed in this pull request?
Introduce
DateTimeConstructorUtils.javawith two static helpers:makeDateExact(int year, int month, int day): wrapsLocalDate.of(...) + DateTimeUtils.localDateToDays(...)in theansiDateTimeArgumentOutOfRange(DateTimeException)try/catch.makeIntervalExact(int years, int months, int weeks, int days, int hours, int mins, Decimal secs): wrapsIntervalUtils.makeIntervalin thearithmeticOverflowError(message, "", null)try/catch.datetimeExpressions.MakeDateandintervalExpressions.MakeIntervaldelegate to the helpers in theirfailOnError = truecodegen + eval paths. The non-ANSI branch keeps the inlinetry/catch -> nullform because it setsisNull = trueon failure.Why are the changes needed?
Part of SPARK-56908 (umbrella). The 7-line try/catch wrapper that maps
DateTimeException/ArithmeticExceptionto the user-facing ANSI error was emitted inline indoGenCode; the helper collapses it to a single call per call site without losing the wrapped exception's message (noQueryContextargument is involved, so this PR introduces no per-rowreferences[]regression).Does this PR introduce any user-facing change?
No.
How was this patch tested?
96/96 pass.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor 1.x