from_dataset re-reads every dimension coordinate on each call, and the workaround loses the cftime UDF and template registry
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Start in XarrayContext.from_dataset, where coord_arrays is built once per call, and in read_xarray_table, which already takes coord_arrays. Also check _registered_datasets and _maybe_register_cftime_udf. Done means one Dataset can register several per-variable tables with each dimension coordinate read once, while metadata recovery and the cftime() UDF still work. The issue proposes two API shapes and the maintainers have not picked one, so confirm the direction before coding.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
XarrayContext.from_dataset materialises the dimension coordinates once per call:
coord_arrays = {
str(dim): input_table.coords[dim].values for dim in input_table.dims
}
Within a single call those arrays are shared across every dim group, which is what the comment above them describes. Across calls nothing is shared. Registering one table per data variable, which is what you want when each variable should be its own SQL table, re-reads every coordinate once per variable.
Measured with a counting DataArray.values property, 4 data variables on a (time, lat, lon) grid:
4 x from_dataset (one per data var): 12 coord reads
1 x from_dataset (whole dataset) : 3 coord reads
Local NumPy makes this free. On a Zarr store each read is a network round trip, so registration cost scales with n_vars * n_dims instead of n_dims.
The obvious workaround is not equivalent
read_xarray_table already accepts coord_arrays, so the natural caller-side fix is to read the coordinates once and register the tables directly:
shared = {str(d): ds.coords[d].values for d in ds.dims}
ctx = XarrayContext()
for v in ds.data_vars:
ctx.register_table(v, read_xarray_table(ds[[v]], chunks, coord_arrays=shared))
That does share the reads, but bypassing from_dataset silently drops two things it does.
-
self._registered_datasets[name] = input_tableis never populated, soXarrayDataFrameloses metadata recovery. Checked:_registered_datasetsis{}afterwards, andto_dataset()then returns empty attrs and cannot inferdims. -
_maybe_register_cftime_udfnever runs, so thecftime()UDF is missing on a 360_day dataset:
cftime() escape hatch : ERR ValueError Error during planning: Invalid function 'cftime'. Did you mean 'to_time'?
cftime() from_dataset : 4 rows
So today there is no public way to register several tables out of one Dataset without either paying n_vars * n_dims coordinate reads or giving up metadata recovery and cftime support.
Possible directions
Either shape would fix it:
- Accept
coord_arraysonfrom_dataset(the parameter already exists one layer down inread_xarray_table), so a caller registering several tables from one parent Dataset can hand in the arrays it already read. - Add a per-variable split to
from_dataset, alongside the existing dim-group split, so a single call can registerair,humand so on as separate tables from one Dataset. This keeps the coordinate sharing, the_registered_datasetstracking and the cftime UDF registration together in one place.
Parent: #126
- Ngôn ngữ chính
- Python
- Star
- 142
- Fork
- 19
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của xqlsystems/xarray-sql
-
documentation
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
xqlsystems/xarray-sql#268 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
xqlsystems/xarray-sql#267 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 74/100
xqlsystems/xarray-sql#243 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
publish.yml: the TestPyPI verification step is unreachable (and installs the wrong package name)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
xqlsystems/xarray-sql#242 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
xqlsystems/xarray-sql#237 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của xqlsystems/xarray-sql
Issue tương tự
-
Edit tool converts CRLF files to LFCó thể đã có người làm @RaphaelFakhri đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
huggingface/tau#774 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
show ignores the row limit when a column or table name contains "limit"Có thể đã có người làm @RaphaelFakhri đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Agents panel: Codex token stats always empty because Codex now writes `*.jsonl.zst` sessionsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 2 ngày
-
documentation good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
eclipse-score/inc_someip_gateway#356 ·
Maintainer thường phản hồi trong vòng 2 ngày