bug: SQL array literals take the type of their first element, so [0, 0.5, 1], [NULL, 1] and [] fail
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
Direzione di ricerca
The fix lives in the SQLExpr::Array branch of Planner::parse_sql_expr in rust/lance-datafusion/src/planner.rs, where the first element currently fixes the element type and the rest are concatenated. Read that branch first, then compare with DataFusion's make_array behaviour for numeric widening, null elements and the empty-list case. Reproduce with the Python ds.update snippet; done means [0, 0.5, 1], [NULL, 1], [1, NULL] and [] all plan to a sensible list type while [1, 'a'] still errors. Note a pull request (#11115) is already open against this, so coordinate before starting.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
An SQL array literal takes the type of its first element and coerces every other element to that type. So [0, 0.5, 1] fails with Array expressions must have a consistent datatype. Expected: Int64, got: Float64, while [0.5, 0, 1] works. A NULL element fails in any position: [NULL, 1] gives Expected: Null, got: Int64, and [1, NULL] gives It is not possible to concatenate arrays of different data types. An empty literal [] fails with concat requires input of at least one array.
This shows up in update on list and vector columns, for example from the LanceDB JS client, which writes the whole number 0 as 0. The code is the SQLExpr::Array branch of Planner::parse_sql_expr in rust/lance-datafusion/src/planner.rs.
Steps to reproduce
import tempfile
import lance
import pyarrow as pa
ds = lance.write_dataset(
pa.table({"id": [1, 2], "f": pa.array([[1.0], [3.5]], pa.list_(pa.float64()))}),
tempfile.mkdtemp(),
)
ds.update({"f": "[0.5, 0, 1]"}, where="id = 1") # works
ds.update({"f": "[0, 0.5, 1]"}, where="id = 1")
# ValueError: Invalid user input: Array expressions must have a consistent datatype. Expected: Int64, got: Float64
ds.update({"f": "[1, NULL]"}, where="id = 1")
# ValueError: ... It is not possible to concatenate arrays of different data types
ds.update({"f": "[]"}, where="id = 1")
# ValueError: ... concat requires input of at least one array
Vector (FixedSizeList<float32>) columns fail the same way with [0, 0.5, 1] and [NULL, 1].
Expected behavior
Element order should not matter. The literal should use the type all elements share, as DataFusion's make_array does: [0, 0.5, 1] becomes [0.0, 0.5, 1.0], NULL becomes a null element, and [] becomes an empty list. Elements with no shared type, such as [1, 'a'], should still be rejected.
Lance version
pylance 15.0.0-beta.22 (49e29d7be). The planner code is unchanged on main 8888a674d.
- Lingua principale
- Rust
- Stelle
- 7.3k
- Fork
- 929
- Merge medio
- 2g 22h
- PR unite (30g)
- 572
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di lance-format/lance
-
bug(python): read_transaction raises TypeError on a Rewrite with rewritten indicesForse già presa @Borg93 l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
lance-format/lance#11117 ·
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
lance-format/lance#10782 ·
I maintainer di solito rispondono entro 2 giorni
-
Upgrade DataFusion for the unparser stack-overflow fixForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
lance-format/lance#8225 ·
I maintainer di solito rispondono entro 2 giorni
-
enhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
lance-format/lance#6425 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
Expose compute_pq_distanceForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertaenhancement
Difficoltà 1/5 1-3 ore Idoneità per principianti 62/100
lance-format/lance#5675 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di lance-format/lance
Issue simili
-
area:cli area:security bug priority:medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
rtk-ai/rtk#5127 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
status: new topic: ga4gh-sdk type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
comp-rbac
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
ClickHouse/ClickHouse#131875 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
googleworkspace/cli#984 ·
I maintainer di solito rispondono entro 1 giorno