apache / apache/datafusion

panic: date_bin overflows scaling extreme Time64(Microsecond) source

Open
#22,212 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Describe the bug

`date_bin` panics during planning/constant folding when scaling an extreme `Time64(Microsecond)` source value.

### To Reproduce

```sql
EXPLAIN SELECT date_bin(
INTERVAL '1 microsecond',
arrow_cast(9223372036854775807, 'Time64(Microsecond)'),
arrow_cast(0, 'Time64(Microsecond)')
);
```

### Actual behavior

```text
thread 'main' panicked at datafusion/functions/src/datetime/date_bin.rs:669:56:
attempt to multiply with overflow
```

### Expected behavior

Return a DataFusion error for the out-of-range time conversion, not a panic.

Contributor guide

Open the contributing guide

Research direction

Reproduce the EXPLAIN query from the issue, then inspect datafusion/functions/src/datetime/date_bin.rs around line 669 and trace the date_bin constant-folding path. Done means the extreme Time64(Microsecond) input returns a DataFusion error for the out-of-range conversion instead of panicking.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.