Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Document that NaN in a data variable is read as SQL NULL

Aperta Adatta ai principianti
#268 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
1-3 ore
Idoneità per principianti
85/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
documentation

Direzione di ricerca

Inizia controllando la conversione in xarray_sql/df.py e i dialetti ADBC, quindi consulta docs/limitations.md e la documentazione sulla lettura per trovare il posto migliore in cui inserire questa nota. Documenta che NaN in una variabile di dati diventa SQL NULL, che le funzioni di aggregazione lo ignorano e che non c’è modo di leggerlo come valore NaN.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

documentation

xarray-sql turns NaN in a data variable into SQL NULL when it scans a Dataset (pa.array(..., from_pandas=True) in xarray_sql/df.py, and the same in the ADBC dialects). That is deliberate, so aggregates skip missing values the way xarray's skipna does. I couldn't find it in the user docs, though, and it surprised me.

What I expected

That a float NaN stays NaN, as it does in a Parquet file or an Arrow table registered directly, and that SUM over a column with a NaN returns NaN.

What happens

import numpy as np, xarray as xr, xarray_sql as xql

ds = xr.Dataset({"x": (("t",), [1.0, np.nan, 2.0])}, coords={"t": [0, 1, 2]})
ctx = xql.Context()
ctx.from_dataset("v", ds)
ctx.sql("SELECT SUM(x) AS s, COUNT(x) AS n, COUNT(*) AS rows FROM v").to_pandas()
# s = 3.0, n = 2, rows = 3

isnan(x) on that row is NULL, not true, and DuckDB through xql.register behaves the same.

Where it mattered

A check that attention masks pairs out rather than weighting them by zero put a NaN in V and expected it to reach only the queries allowed to see it. Every output stayed finite, because the NaN had become a NULL that SUM skipped. The check uses +inf instead, which xarray-sql keeps as a value.

Suggestion

Document it, for example in docs/limitations.md or the reading docs: NaN in a data variable is read as NULL; aggregates skip it; there's no way to read a NaN as a value. Whether to offer an option to keep NaN is a separate question.

Lingua principale
Python
Stelle
142
Fork
19
Merge medio
1g 9h
PR unite (30g)
9

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di xqlsystems/xarray-sql

Tutte le issue di xqlsystems/xarray-sql

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.