Skip to content

panic: date_bin compute_distance subtracts past i64::MIN #22215

@Dandandan

Description

@Dandandan

Describe the bug

date_bin can panic during planning/constant folding when computing the distance for a negative timestamp near i64::MIN.

To Reproduce

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

Actual behavior

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

Expected behavior

Return a planning error for the unrepresentable bin computation instead of panicking.

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