Displaying a `Date64` scalar of `i64::MIN` panics
- Lingua principale
- Rust
- Stelle
- 9.3k
- Fork
- 2.4k
- Merge medio
- 3g 11h
- PR unite (30g)
- 360
Descrizione
### 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
```sql
EXPLAIN SELECT arrow_cast(-9223372036854775808, 'Date64');
```
```text
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`:
```sql
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`.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia in datafusion/common/src/scalar/mod.rs, nel ramo Date64 di impl fmt::Display for ScalarValue, quindi riproduci il fallimento con EXPLAIN SELECT arrow_cast(-9223372036854775808, 'Date64'). Controlla la gestione adiacente degli offset di epoch non rappresentabili. Il lavoro è completo quando la visualizzazione di questo valore i64::MIN non provoca più un panic e segue il comportamento esistente per la stringa vuota.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rust
- Ambito
- data-engineering
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Attiva
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 84/100