xiedeyantu opened a new pull request, #22262: URL: https://github.com/apache/datafusion/pull/22262
## Which issue does this PR close? - Closes #22209 ## Rationale for this change `date_trunc` can panic during planning and constant folding when it receives extreme non-nanosecond timestamps. The overflow happens while converting values to nanoseconds, so a valid SQL query can crash the planner instead of returning a proper error. This change makes that path fail gracefully with a planning error. ## What changes are included in this PR? - Adds overflow checks to the timestamp scale conversion used by `date_trunc`. - Converts the panic into a normal out-of-range planning error. - Adds regression coverage for extreme `Timestamp(Second)`, `Timestamp(Millisecond)`, and `Timestamp(Microsecond)` inputs. - Adds a SQL-level regression test for the `arrow_cast(...)` plus `date_trunc(...)` repro. ## Are these changes tested? - Yes. I added regression tests and verified the repro now returns an error instead of panicking. ## Are there any user-facing changes? - Yes. Out-of-range timestamp inputs now produce a planning error rather than aborting the query with a panic. -- 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]
