`min` / `max` over a list of lists (or of structs) fails with "Internal error: Uncomparable values"
- Lingua principale
- Rust
- Stelle
- 9.3k
- Fork
- 2.4k
- Merge medio
- 3g 11h
- PR unite (30g)
- 360
Descrizione
### Describe the bug
`ScalarValue::partial_cmp` for list values (`partial_cmp_list` in `datafusion/common/src/scalar/mod.rs`) compares the elements with the `arrow::compute::kernels::cmp::lt` / `eq` kernels. Those kernels reject nested element types, so the comparison returns `None` and callers report an internal error. `min` / `max` are the most visible callers, but anything that orders list scalars is affected.
### To Reproduce
```sql
SELECT min(column1), max(column1) FROM VALUES ([[1, 2]]), ([[1, 3]]);
```
```text
Internal error: Uncomparable values: List([[1, 2]]), List([[1, 3]]).
This issue was likely caused by a bug in DataFusion's code. Please help us to resolve this by filing a bug report in our issue tracker: https://github.com/apache/datafusion/issues
```
Same for a list of structs: `SELECT min(column1) FROM VALUES ([struct(1, 'a')]), ([struct(2, 'b')]);`
Comparing the same values with the binary operators (`[[1, 2]] < [[1, 3]]`) works, since that path uses the array comparison kernels directly.
### Expected behavior
Lists of nested values compare lexicographically like lists of primitives do, so `min` returns `[[1, 2]]` and `max` returns `[[1, 3]]`.
### Additional context
Found while running a corpus of aggregate queries over nested types against `datafusion-cli`.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia in datafusion/common/src/scalar/mod.rs, in corrispondenza di ScalarValue::partial_cmp e partial_cmp_list, quindi segui il confronto delle liste utilizzato da min e max. Aggiungi una copertura di regressione per le liste contenenti liste annidate e structs e verifica che gli esempi SQL restituiscano [[1, 2]] per min e [[1, 3]] per max senza un errore interno.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rust
- Ambito
- databases
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Attiva
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 78/100