apache / apache/datafusion

An invalid `datafusion.format.*_format` string panics when results are printed

Offen
#24,909 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Rust
Sterne
9.3k
Forks
2.4k
Ø Merge
3 T. 11 Std.
Gemergte PRs (30 T.)
360

Beschreibung

### Describe the bug

The `datafusion.format.{date,datetime,timestamp,timestamp_tz,time}_format` options are passed straight to `arrow::util::display::FormatOptions` (`TryFrom<&FormatOptions>` in `datafusion/common/src/config.rs`). An invalid `strftime` specification is only detected while a value is rendered: the arrow `Display` impl returns `fmt::Error`, and callers that use `format!` / `to_string` (for example `datafusion-cli`'s table printer when the row limit is hit) turn that into a panic.

### To Reproduce

```sql
SET datafusion.format.time_format = '%';
SELECT time '12:00:00';
```

```text
thread 'main' panicked at library/alloc/src/string.rs:2929:14:
a Display implementation returned an error unexpectedly
```

(`datafusion-cli/src/print_format.rs:138` via `format!("{formatted}")`.) The same happens with `datafusion.format.timestamp_format = '%'` and `SELECT to_timestamp(0)`, and with `date_format`.

### Expected behavior

`SET` or, at the latest, the conversion to arrow's `FormatOptions` should reject the string with a configuration error naming the option, the way `datafusion.execution.parquet.writer_version` is validated.

### Additional context

Found while running a corpus of extreme configuration values against a debug build of `datafusion-cli`.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne in datafusion/common/src/config.rs bei der TryFrom<&FormatOptions>-Konvertierung und untersuche dann datafusion-cli/src/print_format.rs:138 und reproduziere die SET/SELECT-Beispiele. Verfolge, wo ungültige strftime-Zeichenfolgen erstmals validiert werden, und überprüfe, dass die benannten Formatoptionen einen Konfigurationsfehler statt einer Rendering-Panik erzeugen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
rust
Bereich
backend, cli
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Aktiv
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
78/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.