Summary
XarrayContext.from_dataset (via read_xarray_table -> df.py) fails to register several common NetCDF/xarray datasets, because it derives the Arrow schema and block statistics from numpy dtypes alone:
-
Object-dtype variables/coordinates are rejected. _parse_schema calls pa.from_numpy_dtype(var.dtype), which raises ArrowNotImplementedError: Unsupported numpy type 17 for object dtype. That is exactly what a cftime time coordinate (any non-standard calendar such as noleap/360_day) or a string variable produces.
-
Datetimes outside the datetime64[ns] range overflow. _block_metadata coerces datetime min/max to nanoseconds with int(pd.Timestamp(min_val).value), so coordinates with early/late dates (paleoclimate records, or anything before ~1678 / after ~2262) raise OverflowError, even at us resolution.
Reproduce
Object dtype (string variable shown; a cftime time coordinate produces the same Unsupported numpy type 17):
import numpy as np, xarray as xr
from xarray_sql import XarrayContext
ds = xr.Dataset({"label": (["x"], np.array(["a", "b"], dtype=object))}, coords={"x": [1, 2]})
XarrayContext().from_dataset("t", ds, chunks={"x": 2})
# pyarrow.lib.ArrowNotImplementedError: Unsupported numpy type 17
Out-of-ns-range datetimes:
import numpy as np, xarray as xr
from xarray_sql import XarrayContext
times = xr.date_range("0001-01-01", periods=3, freq="100YS", use_cftime=True).to_datetimeindex(time_unit="us")
ds = xr.Dataset({"v": (["time"], np.arange(3.0))}, coords={"time": times})
XarrayContext().from_dataset("t", ds, chunks={"time": 2})
# OverflowError: Cannot convert Timestamp to nanoseconds without overflow
Real-world impact
NetCDF/climate files routinely use non-standard calendars, so xarray decodes their time coordinate to cftime (object dtype) and (1) fires immediately. Long or paleoclimate records additionally hit (2). Between them a large class of real .nc files cannot be registered.
Suggested fixes
_parse_schema: handle object/datetime dtypes rather than passing them straight to pa.from_numpy_dtype. Infer from data (pa.array(...).type), map cftime/datetime to a pa.timestamp, strings to pa.string().
_block_metadata: use the array's native unit instead of forcing ns, e.g. min_val.asm8.view("i8") with the matching timestamp_<unit> tag (the OverflowError message itself suggests .asm8.view('i8')).
Environment
xarray-sql 0.2.1, pyarrow 23.0.1, xarray 2026.2.0, pandas 3.0.1, numpy 2.4.2, Python 3.14.3
Found via HoloViz Lumen's XArraySQLSource, where uploading a .nc with a non-standard-calendar time coordinate hits this. Repros verified locally.
Summary
XarrayContext.from_dataset(viaread_xarray_table->df.py) fails to register several common NetCDF/xarray datasets, because it derives the Arrow schema and block statistics from numpy dtypes alone:Object-dtype variables/coordinates are rejected.
_parse_schemacallspa.from_numpy_dtype(var.dtype), which raisesArrowNotImplementedError: Unsupported numpy type 17for object dtype. That is exactly what a cftime time coordinate (any non-standard calendar such asnoleap/360_day) or a string variable produces.Datetimes outside the
datetime64[ns]range overflow._block_metadatacoerces datetime min/max to nanoseconds withint(pd.Timestamp(min_val).value), so coordinates with early/late dates (paleoclimate records, or anything before ~1678 / after ~2262) raiseOverflowError, even atusresolution.Reproduce
Object dtype (string variable shown; a cftime time coordinate produces the same
Unsupported numpy type 17):Out-of-ns-range datetimes:
Real-world impact
NetCDF/climate files routinely use non-standard calendars, so xarray decodes their time coordinate to cftime (object dtype) and (1) fires immediately. Long or paleoclimate records additionally hit (2). Between them a large class of real
.ncfiles cannot be registered.Suggested fixes
_parse_schema: handle object/datetime dtypes rather than passing them straight topa.from_numpy_dtype. Infer from data (pa.array(...).type), map cftime/datetime to apa.timestamp, strings topa.string()._block_metadata: use the array's native unit instead of forcing ns, e.g.min_val.asm8.view("i8")with the matchingtimestamp_<unit>tag (theOverflowErrormessage itself suggests.asm8.view('i8')).Environment
xarray-sql 0.2.1, pyarrow 23.0.1, xarray 2026.2.0, pandas 3.0.1, numpy 2.4.2, Python 3.14.3
Found via HoloViz Lumen's
XArraySQLSource, where uploading a.ncwith a non-standard-calendar time coordinate hits this. Repros verified locally.