gengliangwang opened a new pull request, #55940: URL: https://github.com/apache/spark/pull/55940
**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.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. ### 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 is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
