[SPARK-57169][SQL] Simplify NextDay codegen under ANSI mode#56219
Open
gengliangwang wants to merge 1 commit into
Open
[SPARK-57169][SQL] Simplify NextDay codegen under ANSI mode#56219gengliangwang wants to merge 1 commit into
gengliangwang wants to merge 1 commit into
Conversation
### What changes were proposed in this pull request?
Add `DateTimeExpressionUtils.getNextDateExact(int startDate, UTF8String
dayOfWeek)` and route `NextDay`'s ANSI (`failOnError = true`) eval and codegen
paths through it.
In ANSI mode the previous codegen emitted
`try { ... } catch (SparkIllegalArgumentException e) { throw e; }` -- a no-op
catch that simply rethrew the same exception. The ANSI branch now emits a single
`getNextDateExact(...)` call with no try/catch (the helper lets the
`SparkIllegalArgumentException` from `getDayOfWeekFromString` propagate, which is
exactly the ANSI behavior). The non-ANSI branch keeps the inline
`try/catch -> isNull`. The `dayOfWeek.foldable` constant-folding fast path is
unchanged.
### Why are the changes needed?
Part of SPARK-56908 (umbrella). Dropping the dead try/catch wrapper (and the two
chained `DateTimeUtils` calls) in the ANSI path shrinks the generated Java for
`next_day`.
### 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"
```
75/75 pass, including `next_day` (exercised both with and without whole-stage
codegen).
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8)
Co-authored-by: Isaac
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.
What changes were proposed in this pull request?
Add
DateTimeExpressionUtils.getNextDateExact(int startDate, UTF8String dayOfWeek)and routeNextDay's ANSI (failOnError = true) eval and codegen paths through it.In ANSI mode the previous codegen emitted
try { ... } catch (SparkIllegalArgumentException e) { throw e; }-- a no-op catch that simply rethrew the same exception. The ANSI branch now emits a singlegetNextDateExact(...)call with no try/catch (the helper lets theSparkIllegalArgumentExceptionfromDateTimeUtils.getDayOfWeekFromStringpropagate, which is exactly the ANSI behavior). The non-ANSI branch keeps the inlinetry/catch -> isNullform (matching the already-mergedMakeDate/MakeIntervalcleanups). ThedayOfWeek.foldableconstant-folding fast path is unchanged. The eval path delegates to the same helper for consistency.Why are the changes needed?
Part of SPARK-56908 (umbrella). Dropping the dead try/catch wrapper (and the two chained
DateTimeUtilscalls) in the ANSI path shrinks the generated Java fornext_day, helping with the JVM 64KB method / constant-pool limits, Janino compile time, and JIT work.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?
75/75 pass, including
next_day(exercised both with and without whole-stage codegen).Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8)