mbutrovich opened a new pull request, #26686: URL: https://github.com/apache/datafusion/pull/26686
## Which issue does this PR close? - Closes #26678. - Closes #14738. - Closes #26685. ## Rationale for this change These fixes depend on each other. #26678 and #14738 come from the same [NULL-as-zero branch](https://github.com/apache/datafusion/blob/dad9063becc0b10550936425d8b433046c5622e3/datafusion/functions/src/datetime/date_part.rs#L490-L499). Fixing #14738 makes `millisecond` and `microsecond` of a long duration return NULL instead of a wrapped value. Without the #26685 fix, that NULL fails with `declared as non-nullable` on a non-nullable input, so fixing #14738 alone would replace a wrong result with an error. ## What changes are included in this PR? - `millisecond`, `microsecond` and `nanosecond` share one function that reuses arrow's `date_part` and `cast` where they compute the right value. - A value that overflows the return type is NULL, as arrow already does for durations. Should overflow be an error instead? That would change other parts too, so I'd rather do it separately. - The integer parts of `date_part` and the Spark `date_part` are nullable again, as before #19823 (53.0.0). `epoch` keeps the input's nullability. - The first commit (c920a5b92) adds benchmark cases without the fix, so the benchmark bot can compare against it. ## What is the testing strategy for this PR? New cases in `datafusion/sqllogictest/test_files/datetime/date_part.slt` and a unit test in `datafusion/spark/src/function/datetime/date_part.rs`. ## Are there any user-facing changes? `EXTRACT(MILLISECOND/MICROSECOND/NANOSECOND)` on `Duration` and `Interval` return correct results, and long durations return NULL instead of a wrapped value or a panic. The result of `date_part` (except `epoch`) and of the Spark `date_part` is nullable, as before 53.0.0. There are no public API changes. ## AI Disclosure I wrote this PR with help from Claude but understand and support the core approach, implementation, and test coverage. -- 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]
