geographybuff opened a new pull request, #26139: URL: https://github.com/apache/datafusion/pull/26139
## Which issue does this PR close? - Closes #24892. ## Rationale for this change `impl fmt::Display for ScalarValue` unwraps `chrono::Duration::try_milliseconds(v)` in the `Date64` arm. That returns `None` for `i64::MIN`, which `Duration` cannot represent, so printing such a literal panics, for example `EXPLAIN SELECT arrow_cast(-9223372036854775808, 'Date64')`. #24893 proposed the same change and was closed as part of a batch of PRs, not on its merits. This PR redoes it on current `main`. ## What changes are included in this PR? `try_milliseconds` and `checked_add_signed` are chained with `and_then`, so a value `Duration` cannot hold falls into the existing `None => ""` branch. That's how the neighbouring out-of-range case already formats (added for apache/arrow-rs#7728). One file, +7/-1. ## What is the testing strategy for this PR? `test_display_date64_large_values` now also checks `i64::MIN` and `i64::MAX`: - Without the fix it panics at the same `unwrap` (`scalar/mod.rs:5651`). - With the fix, `cargo test -p datafusion-common --lib` passes 623 tests, and `rustfmt --check` is clean. `cargo clippy -p datafusion-common --all-targets -- -D warnings` fails locally on an unused import in `config.rs:4157`. That happens on unmodified `main` too, probably because I ran without the `parquet` feature, so it's unrelated. **Not verified:** the issue's second reproduction, a `RANGE` window frame over a `Date64` column containing `i64::MIN`. I only ran the unit test. If that path panics somewhere other than this `Display` impl, this PR doesn't fix it. ## Are there any user-facing changes? No panic: a `Date64` of `i64::MIN` displays as an empty string, like other out-of-range dates. **AI disclosure:** prepared with Claude Code (Claude Opus 5.5), which wrote the change and the test and ran the commands above. -- 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]
