Displaying a `Date64` scalar of `i64::MIN` panics
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust
- Domain
- data-engineering
Research direction
Start in datafusion/common/src/scalar/mod.rs at the Date64 arm of impl fmt::Display for ScalarValue, then reproduce the failure with EXPLAIN SELECT arrow_cast(-9223372036854775808, 'Date64'). Check the neighbouring handling for unrepresentable epoch offsets. Done means displaying this i64::MIN value no longer panics and follows the existing empty-string behavior.
Written by the indexing model from the issue text.
Description
Describe the bug
Formatting a ScalarValue::Date64 whose value is i64::MIN panics. The Display impl unwraps chrono::Duration::try_milliseconds(v), which returns None for i64::MIN because that value is outside the range chrono::Duration can represent (datafusion/common/src/scalar/mod.rs, Date64 arm of impl fmt::Display for ScalarValue).
Any code path that prints such a literal hits it, e.g. plan display.
To Reproduce
EXPLAIN SELECT arrow_cast(-9223372036854775808, 'Date64');
thread 'main' panicked at datafusion/common/src/scalar/mod.rs:5661:82:
called `Option::unwrap()` on a `None` value
Also reachable during execution, e.g. a RANGE window frame over a Date64 column that contains i64::MIN:
SELECT count(*) OVER (ORDER BY x RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)
FROM (VALUES (arrow_cast(9223372036854775807, 'Date64')), (arrow_cast(-9223372036854775808, 'Date64'))) t(x);
Expected behavior
No panic. The neighbouring branch already maps an unrepresentable epoch offset to an empty string (added for apache/arrow-rs#7728); i64::MIN should behave the same way.
Additional context
Found while running a corpus of extreme-value literals against a debug build of datafusion-cli.
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 354
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/datafusion
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
apache/datafusion#25266 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
apache/datafusion#25213 · 1 comment ·
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
apache/datafusion#25168 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
apache/datafusion#24998 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/datafusion#24913 ·
All issues in apache/datafusion
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
bitcoindevkit/bdk-ffi#1125 ·