benbellick opened a new pull request, #25430: URL: https://github.com/apache/datafusion/pull/25430
## Which issue does this PR close? Closes #25425. ## Rationale for this change Scalar `date_trunc` rounds negative subsecond timestamps toward zero, while array evaluation floors them to the start of the containing unit. This makes the result depend on whether the same value is evaluated as a scalar or a column. ## What changes are included in this PR? Use checked Euclidean truncation for scalar microsecond-to-millisecond and nanosecond-to-microsecond/millisecond conversions. This matches array semantics and returns an error when flooring would underflow. ## Are these changes tested? Yes. Unit tests cover negative timestamps for all three affected conversions and underflow at the nanosecond lower bound. The full workspace extended test suite and strict all-target, all-feature Clippy checks pass. ## Are there any user-facing changes? Scalar and array `date_trunc` now agree for negative subsecond timestamps. --- Note: This PR was developed with AI assistance. All changes have been reviewed, and I take full responsibility for this contribution. -- 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]
