stevomitric opened a new pull request, #57224:
URL: https://github.com/apache/spark/pull/57224
### What changes were proposed in this pull request?
Extend `date_trunc` (`TruncTimestamp`) to accept nanosecond-precision
timestamps (`TIMESTAMP_NTZ(p)`/`TIMESTAMP_LTZ(p)`, p in [7, 9]) in addition to
microsecond `TimestampType`. The result keeps the input's nanos type/family;
truncation floors `epochMicros` (NTZ at UTC, LTZ in the session zone) and
always zeroes the sub-microsecond remainder, since `date_trunc`'s finest unit
is MICROSECOND. Adds `DateTimeUtils.truncTimestampNanos` delegating to the
existing `truncTimestamp`.
### Why are the changes needed?
`date_trunc` previously narrowed a nanosecond argument to microseconds,
dropping the sub-microsecond digits and forcing an LTZ result even for NTZ
input.
### Does this PR introduce _any_ user-facing change?
Yes. `date_trunc(fmt, ts_nanos)` now returns the same nanosecond type/family
with correct truncation (preview `spark.sql.timestampNanosTypes.enabled`).
### How was this patch tested?
`DateExpressionsSuite` 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]