stevomitric opened a new pull request, #57225:
URL: https://github.com/apache/spark/pull/57225
### What changes were proposed in this pull request?
Extend `DateFormatClass` (which backs `date_format`, `to_char` and
`to_varchar`) to accept nanosecond-precision timestamps
(`TIMESTAMP_NTZ(p)`/`TIMESTAMP_LTZ(p)`, p in [7, 9]). Both eval and codegen
render via the nanosecond-aware `TimestampFormatter`: NTZ renders its wall
clock zone-independently, LTZ renders in the session zone, and sub-precision
digits floor to zeros. Also guards `SimplifyDateTimeConversions` from rewriting
a nanosecond child, whose round-trip through microsecond `TimestampType` would
silently truncate.
### Why are the changes needed?
Nanosecond input was narrowed to microseconds, so the sub-microsecond digits
never reached the formatter.
### Does this PR introduce _any_ user-facing change?
Yes. `date_format`/`to_char`/`to_varchar` now render nanosecond timestamps
at full precision (preview `spark.sql.timestampNanosTypes.enabled`).
### How was this patch tested?
`DateExpressionsSuite`, `SimplifyDateTimeConversionsSuite`,
`TimestampNanosFunctionsSuiteBase`, and `timestamp-{ltz,ntz}-nanos.sql` golden
files.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code
--
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]