Skip to content

date_bin should error when the computed timestamp bin is out of range #26605

Closed
benbellick/datafusion
#5

Description

@benbellick

Describe the bug

date_bin returns NULL when a valid non-null timestamp’s computed bin falls outside the output timestamp type’s range.

#22215 requested an error instead of a panic. Its fix, #22408, prevented the panic but returned NULL instead.

To Reproduce

SELECT date_bin(
  INTERVAL '3 nanoseconds',
  arrow_cast(-9223372036854775808, 'Timestamp(Nanosecond, None)'),
  TIMESTAMP '1970-01-01 00:00:00'
);

Currently returns NULL because the containing bin starts below the minimum representable nanosecond timestamp.

Expected behavior

Return an error for an unrepresentable bin, matching PostgreSQL’s behavior.

Preserve the scalar/array consistency established by #22528 and #22610. Equivalent scalar and column inputs should return the same valid bin or both error. NULL timestamp inputs should remain NULL, and representable bins should continue to succeed even when intermediate arithmetic requires a wider type.

Additional context

Related to the audit in #25344. This change does not enable date_bin range-locality analysis.

Willingness to contribute

I plan to contribute a fix for this bug independently

Activity

  1. benbellick commented on Oct 22, 2026

    @benbellick
    ContributorAuthor

    take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions