Skip to content

panic: date_bin overflows subtracting extreme nanosecond timestamp origin #22210

@Dandandan

Description

@Dandandan

Describe the bug

date_bin panics during planning/constant folding when subtracting an extreme timestamp origin from an extreme source timestamp.

To Reproduce

EXPLAIN SELECT date_bin(
  INTERVAL '1 nanosecond',
  arrow_cast(9223372036854775807, 'Timestamp(Nanosecond, None)'),
  arrow_cast(-9223372036854775808, 'Timestamp(Nanosecond, None)')
);

Actual behavior

thread 'main' panicked at datafusion/functions/src/datetime/date_bin.rs:324:21:
attempt to subtract with overflow

Expected behavior

DataFusion should return a planning error for the unrepresentable timestamp difference, not panic.

Notes

The failing operation is the source-origin difference in the date_bin implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions