Repository navigation
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Found via fuzzing.
To Reproduce
select DATE_BIN('1637426858', TO_TIMESTAMP_MILLIS(1040292460), TIMESTAMP '1984-01-07 00:00:00');
Yields
thread 'main' (43082114) panicked at /Users/neilconway/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/chrono-0.4.43/src/datetime/mod.rs:1750:38:
`DateTime - Months` out of range
stack backtrace:
0: __rustc::rust_begin_unwind
at /rustc/ded5c06cf21d2b93bffd5d884aa6e96934ee4234/library/std/src/panicking.rs:698:5
1: core::panicking::panic_fmt
at /rustc/ded5c06cf21d2b93bffd5d884aa6e96934ee4234/library/core/src/panicking.rs:80:14
2: core::panicking::panic_display
at /rustc/ded5c06cf21d2b93bffd5d884aa6e96934ee4234/library/core/src/panicking.rs:264:5
3: core::option::expect_failed
at /rustc/ded5c06cf21d2b93bffd5d884aa6e96934ee4234/library/core/src/option.rs:2183:5
4: core::option::Option<T>::expect
at /Users/neilconway/.rustup/toolchains/1.92.0-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/option.rs:970:21
5: <chrono::datetime::DateTime<Tz> as core::ops::arith::Sub<chrono::month::Months>>::sub
at /Users/neilconway/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/chrono-0.4.43/src/datetime/mod.rs:1750:38
6: datafusion_functions::datetime::date_bin::date_bin_months_interval
at ./datafusion/functions/src/datetime/date_bin.rs:358:9
7: datafusion_functions::datetime::date_bin::date_bin_impl::stride_map_fn::{{closure}}
at ./datafusion/functions/src/datetime/date_bin.rs:557:23
[...]
select DATE_BIN('1637426858', TO_TIMESTAMP_MILLIS(-1040292460), TIMESTAMP '1984-01-07 00:00:00');
Yields
thread 'main' (43083083) panicked at datafusion/functions/src/datetime/date_bin.rs:380:42:
called `Option::unwrap()` on a `None` value
stack backtrace:
0: __rustc::rust_begin_unwind
at /rustc/ded5c06cf21d2b93bffd5d884aa6e96934ee4234/library/std/src/panicking.rs:698:5
1: core::panicking::panic_fmt
at /rustc/ded5c06cf21d2b93bffd5d884aa6e96934ee4234/library/core/src/panicking.rs:80:14
2: core::panicking::panic
at /rustc/ded5c06cf21d2b93bffd5d884aa6e96934ee4234/library/core/src/panicking.rs:150:5
3: core::option::unwrap_failed
at /rustc/ded5c06cf21d2b93bffd5d884aa6e96934ee4234/library/core/src/option.rs:2174:5
4: core::option::Option<T>::unwrap
at /Users/neilconway/.rustup/toolchains/1.92.0-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/option.rs:1015:21
5: datafusion_functions::datetime::date_bin::to_utc_date_time
at ./datafusion/functions/src/datetime/date_bin.rs:380:42
6: datafusion_functions::datetime::date_bin::date_bin_months_interval
at ./datafusion/functions/src/datetime/date_bin.rs:346:23
7: datafusion_functions::datetime::date_bin::date_bin_impl::stride_map_fn::{{closure}}
at ./datafusion/functions/src/datetime/date_bin.rs:557:23
[...]
Expected behavior
No response
Additional context
No response
Reacted by Andrew Lamb
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
iampratap7997-dot commentedon Feb 8, 2026
Hi, I’d like to work on this issue.
Please let me know if it is still available .
Thanks.
neilconway commentedon Feb 8, 2026
@iampratap7997-dot It is still available, go for it!
mishop-15 commentedon Feb 8, 2026
@neilconway I've opened PR #20221 to fix this issue - both queries now return NULL instead of panicking.
iampratap7997-dot commentedon Feb 8, 2026
Thanks for the PR! I was assigned to this issue.
Let me know if you’d like me to help address the failing checks or follow-up changes.
fix: handle out of range errors in DATE_BIN instead of panicking (#20221
fix: handle out of range errors in DATE_BIN instead of panicking (apa…