benbellick opened a new pull request, #26607: URL: https://github.com/apache/datafusion/pull/26607
## Which issue does this PR close? Closes https://github.com/apache/datafusion/issues/26605. ## Rationale for this change `date_bin` returns NULL for unrepresentable timestamp bins. Return an error instead, matching [PostgreSQL](https://www.db-fiddle.com/f/h3qSHUSRprbzkX9GBkSuY2/0). I'm not sure whether DataFusion has a specific policy on returning NULL versus an error here, but the PostgreSQL precedent seems clear. Returning NULL because we cannot compute a bin for a non-null timestamp silently hides a computation failure rather than representing missing input. This prepares `date_bin` for avoiding aggregate repartitioning in [#25345](https://github.com/apache/datafusion/issues/25345), similar to the `date_trunc` optimization in [#26449](https://github.com/apache/datafusion/pull/26449). It follows the error behavior established for `date_trunc` in [#25131](https://github.com/apache/datafusion/pull/25131). ## What changes are included in this PR? Make scalar and array timestamp-binning failures return `DATE_BIN timestamp out of range`. Preserve NULL inputs and successful wider-arithmetic results. ## What is the testing strategy for this PR? Unit tests and SQLLogicTests cover overflow errors, scalar/array consistency, NULL preservation, and representable results across timestamp precisions. ## Are there any user-facing changes? Previously NULL-producing timestamp-binning failures now fail the query. --- 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]
