Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

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

未關閉 適合新手
#268 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
1/5
預估耗時
1-3 小時
新手友好度
85/100
Issue 類型
文件
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
python
領域
documentation

研究方向

首先檢查 xarray_sql/df.py 中的轉換以及 ADBC 方言,接著查看 docs/limitations.md 和讀取文件,找出最適合加入此說明的位置。說明資料變數中的 NaN 會變成 SQL NULL,彙總函式會略過它,而且無法將它讀取為 NaN 值。

由索引模型根據 Issue 內容生成。

描述

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.

主要語言
Python
星號
142
分支
19
平均合併
1 天 9 小時
30 天內合併 PR
9

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

xqlsystems/xarray-sql 的其他 Issue

查看 xqlsystems/xarray-sql 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。