gengliangwang opened a new pull request, #56218:
URL: https://github.com/apache/spark/pull/56218

   ### What changes were proposed in this pull request?
   
   Add `DateTimeExpressionUtils.parseToTimestampExact(TimestampFormatter 
formatter, String input, long downScaleFactor, boolean forTimestampNTZ, String 
suggestedFuncOnFail)` and route the ANSI (`failOnError = true`) eval and 
codegen paths of `ToTimestamp` (the base of `GetTimestamp` / `to_timestamp`, 
`unix_timestamp`, etc.) through it. The helper parses via 
`parseWithoutTimeZone` (TIMESTAMP_NTZ, no down-scaling) or `parse` + `/ 
downScaleFactor`, and translates a `DateTimeException` (which also covers 
`DateTimeParseException`) or a `ParseException` to `ansiDateTimeParseError`; 
any other exception (e.g. `IllegalStateException`) propagates unchanged, 
matching the previous behavior.
   
   `ToTimestamp.doGenCode` previously emitted the same 5-line `try { parse } 
catch (DateTimeException) catch (ParseException)` block at both string call 
sites (the cached-formatter path and the per-row-formatter path). A local 
`parseTimestampCode` now dispatches on `failOnError`: the ANSI branch emits a 
single `parseToTimestampExact(...)` call, while the non-ANSI branch keeps the 
inline `try/catch -> isNull` form (the same shape used by the already-merged 
`MakeDate` / `MakeInterval` cleanups). The eval path delegates to the same 
helper for consistency.
   
   ### Why are the changes needed?
   
   Part of SPARK-56908 (umbrella). Collapsing the duplicated inline try/catch 
to a single helper call shrinks the generated Java for the common 
`to_timestamp` / `unix_timestamp` family, 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?
   
   ```
   build/sbt "catalyst/testOnly *DateExpressionsSuite"
   ```
   
   75/75 pass (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)


-- 
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]

Reply via email to