neilconway opened a new issue, #20219:
URL: https://github.com/apache/datafusion/issues/20219

   ### 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_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to