benbellick opened a new pull request, #25131: URL: https://github.com/apache/datafusion/pull/25131
## Which issue does this PR close? - Closes #25129. ## Rationale for this change `date_trunc` can panic in debug builds or return an incorrect timestamp in release builds when its array fast path truncates a timestamp near `i64::MIN`. ## What changes are included in this PR? Use checked subtraction in the fine-granularity array path and return an execution error when the truncated timestamp cannot be represented. ## What is the testing strategy for this PR? Added `test_date_trunc_fine_granularity_underflow`, which passes `i64::MIN` through the nanosecond timestamp array path and verifies that `date_trunc` returns an execution error. The original SQL reproduction was also verified with the locally compiled DataFusion CLI. ## Are there any user-facing changes? Invalid extreme timestamp truncations now return an execution error instead of panicking or returning a wrapped timestamp. --- 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]
