Skip to content

Add xarray-sql support#1434

Closed
ahuang11 wants to merge 3 commits into
mainfrom
add_xarray_sql
Closed

Add xarray-sql support#1434
ahuang11 wants to merge 3 commits into
mainfrom
add_xarray_sql

Conversation

@ahuang11

@ahuang11 ahuang11 commented Oct 6, 2025

Copy link
Copy Markdown
Contributor

Just a proof of concept integrating https://github.com/alxmrs/xarray-sql

import xarray as xr
ds = xr.tutorial.open_dataset('air_temperature')
ds.to_netcdf('air.nc')

lumen-ai serve air.nc

image image image

I wonder if this should be a lumen extension, like lumen-anndata. Part of me feels like it should be in core, so it works like hvplot.xarray, but at the same time, unsure about the limitations about the SQL & xarray.

I think if xarray-sql supported xarray-datatrees, then it's possible to rebuild AnndataSource on this since xarray is a generalized library supporting n-D dimension datasets.

@ahuang11
ahuang11 requested a review from philippjfr October 6, 2025 23:07
@droumis

droumis commented Oct 7, 2025

Copy link
Copy Markdown
Member

verrrry interesting.. It would be worthwhile to scope out how well it could support anndata

ghostiee-11 added a commit to ghostiee-11/lumen that referenced this pull request Mar 11, 2026
Adds XArraySQLSource(BaseSQLSource) that uses xarray-sql (Apache DataFusion)
to provide full SQL query capabilities over xarray datasets. Each data variable
is exposed as a separate SQL table with coordinate columns.

Ref: holoviz#1434, holoviz#1508

- New source: lumen/sources/xarray_sql.py
  - SQL queries via DataFusion (postgres-compatible dialect)
  - Supports NetCDF, Zarr, HDF5, GRIB formats
  - Auto-engine detection from file extension
  - Dask-backed lazy chunking
  - Rich metadata from xarray attributes (units, dimensions, coordinates)
  - Dimension info API for UI controls and AI context
  - Async execute/get for non-blocking Lumen AI agents
  - create_sql_expr_source with shared DataFusion context
  - Full to_spec/from_spec serialization
  - Optional import -- graceful fallback when xarray not installed

- Tests: 50 tests covering construction, SQL execution, schema,
  metadata, normalization, serialization, async, resource management

- Optional dependency group: pip install lumen[xarray]
@ahuang11

Copy link
Copy Markdown
Contributor Author

Superseded #1741

@ahuang11 ahuang11 closed this Mar 24, 2026
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants