xarray-sql 0.2.0__cp311-cp311-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- xarray_sql/__init__.py +10 -0
- xarray_sql/_native.cp311-win_amd64.pyd +4 -0
- xarray_sql/core.py +48 -0
- xarray_sql/df.py +172 -0
- xarray_sql/df_test.py +341 -0
- xarray_sql/reader.py +253 -0
- xarray_sql/reader_test.py +944 -0
- xarray_sql/sql.py +18 -0
- xarray_sql/sql_test.py +194 -0
- xarray_sql-0.2.0.dist-info/METADATA +224 -0
- xarray_sql-0.2.0.dist-info/RECORD +13 -0
- xarray_sql-0.2.0.dist-info/WHEEL +4 -0
- xarray_sql-0.2.0.dist-info/licenses/LICENSE +202 -0
xarray_sql/sql.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import xarray as xr
|
|
2
|
+
from datafusion import SessionContext
|
|
3
|
+
|
|
4
|
+
from .df import Chunks
|
|
5
|
+
from .reader import read_xarray_table
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class XarrayContext(SessionContext):
|
|
9
|
+
"""A datafusion `SessionContext` that also supports `xarray.Dataset`s."""
|
|
10
|
+
|
|
11
|
+
def from_dataset(
|
|
12
|
+
self,
|
|
13
|
+
table_name: str,
|
|
14
|
+
input_table: xr.Dataset,
|
|
15
|
+
chunks: Chunks = None,
|
|
16
|
+
):
|
|
17
|
+
table = read_xarray_table(input_table, chunks)
|
|
18
|
+
self.register_table(table_name, table)
|
xarray_sql/sql_test.py
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"""SQL functionality tests for xarray-sql using pytest."""
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
import xarray as xr
|
|
5
|
+
|
|
6
|
+
from . import XarrayContext
|
|
7
|
+
from .df_test import create_large_dataset, rand_wx
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.fixture
|
|
11
|
+
def air_dataset_small():
|
|
12
|
+
ds = xr.tutorial.open_dataset("air_temperature").chunk({"time": 240})
|
|
13
|
+
return ds.isel(time=slice(0, 12), lat=slice(0, 11), lon=slice(0, 10))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@pytest.fixture
|
|
17
|
+
def air_dataset_large():
|
|
18
|
+
return xr.tutorial.open_dataset("air_temperature").chunk({"time": 240})
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@pytest.fixture
|
|
22
|
+
def weather_dataset():
|
|
23
|
+
ds = rand_wx("2023-01-01T00", "2023-01-01T12")
|
|
24
|
+
return ds.isel(time=slice(0, 6), lat=slice(0, 10), lon=slice(0, 10)).chunk(
|
|
25
|
+
{"time": 3}
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@pytest.fixture
|
|
30
|
+
def synthetic_dataset():
|
|
31
|
+
return create_large_dataset(
|
|
32
|
+
time_steps=50, lat_points=20, lon_points=20
|
|
33
|
+
).chunk({"time": 25})
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@pytest.fixture
|
|
37
|
+
def station_dataset():
|
|
38
|
+
return xr.Dataset(
|
|
39
|
+
{
|
|
40
|
+
"station_id": (["station"], [1, 2, 3, 4, 5]),
|
|
41
|
+
"elevation": (["station"], [100, 250, 500, 750, 1000]),
|
|
42
|
+
"name": (
|
|
43
|
+
["station"],
|
|
44
|
+
["Station_A", "Station_B", "Station_C", "Station_D", "Station_E"],
|
|
45
|
+
),
|
|
46
|
+
}
|
|
47
|
+
).chunk({"station": 5})
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@pytest.fixture
|
|
51
|
+
def air_and_stations():
|
|
52
|
+
air = (
|
|
53
|
+
xr.tutorial.open_dataset("air_temperature")
|
|
54
|
+
.isel(time=slice(0, 12), lat=slice(0, 5), lon=slice(0, 8))
|
|
55
|
+
.chunk({"time": 6})
|
|
56
|
+
)
|
|
57
|
+
stations = xr.Dataset(
|
|
58
|
+
{
|
|
59
|
+
"station_id": (["station"], [101, 102, 103]),
|
|
60
|
+
"lat": (
|
|
61
|
+
["station"],
|
|
62
|
+
[air.lat.values[0], air.lat.values[2], air.lat.values[4]],
|
|
63
|
+
),
|
|
64
|
+
"lon": (
|
|
65
|
+
["station"],
|
|
66
|
+
[air.lon.values[1], air.lon.values[3], air.lon.values[5]],
|
|
67
|
+
),
|
|
68
|
+
"elevation": (["station"], [100, 250, 500]),
|
|
69
|
+
}
|
|
70
|
+
).chunk({"station": 3})
|
|
71
|
+
return air, stations
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def test_sanity(air_dataset_small):
|
|
75
|
+
ctx = XarrayContext()
|
|
76
|
+
ctx.from_dataset("air", air_dataset_small)
|
|
77
|
+
result = ctx.sql(
|
|
78
|
+
'SELECT "lat", "lon", "time", "air" FROM "air" LIMIT 100'
|
|
79
|
+
).to_pandas()
|
|
80
|
+
assert len(result) > 0
|
|
81
|
+
assert len(result) <= 1320
|
|
82
|
+
assert all(col in result.columns for col in ["lat", "lon", "time", "air"])
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def test_aggregation_small(air_dataset_small):
|
|
86
|
+
ctx = XarrayContext()
|
|
87
|
+
ctx.from_dataset("air", air_dataset_small)
|
|
88
|
+
query = """
|
|
89
|
+
SELECT lat, lon, SUM(air) AS air_total
|
|
90
|
+
FROM air
|
|
91
|
+
GROUP BY lat, lon
|
|
92
|
+
"""
|
|
93
|
+
result = ctx.sql(query).to_pandas()
|
|
94
|
+
expected_rows = (
|
|
95
|
+
air_dataset_small.sizes["lat"] * air_dataset_small.sizes["lon"]
|
|
96
|
+
)
|
|
97
|
+
assert len(result) == expected_rows
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def test_aggregation_large(air_dataset_large):
|
|
101
|
+
ctx = XarrayContext()
|
|
102
|
+
ctx.from_dataset("air", air_dataset_large)
|
|
103
|
+
query = """
|
|
104
|
+
SELECT lat, lon, AVG(air) AS air_avg
|
|
105
|
+
FROM air
|
|
106
|
+
GROUP BY lat, lon
|
|
107
|
+
"""
|
|
108
|
+
result = ctx.sql(query).to_pandas()
|
|
109
|
+
expected_rows = (
|
|
110
|
+
air_dataset_large.sizes["lat"] * air_dataset_large.sizes["lon"]
|
|
111
|
+
)
|
|
112
|
+
assert len(result) == expected_rows
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def test_basic_select_all(air_dataset_small):
|
|
116
|
+
ctx = XarrayContext()
|
|
117
|
+
ctx.from_dataset("air", air_dataset_small)
|
|
118
|
+
result = ctx.sql("SELECT * FROM air LIMIT 10").to_pandas()
|
|
119
|
+
assert len(result) <= 10
|
|
120
|
+
for col in ["lat", "lon", "time", "air"]:
|
|
121
|
+
assert col in result.columns
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def test_weather_queries(weather_dataset):
|
|
125
|
+
ctx = XarrayContext()
|
|
126
|
+
ctx.from_dataset("weather", weather_dataset)
|
|
127
|
+
# Selecting specific columns
|
|
128
|
+
result = ctx.sql(
|
|
129
|
+
"SELECT lat, lon, temperature, precipitation FROM weather LIMIT 20"
|
|
130
|
+
).to_pandas()
|
|
131
|
+
assert "temperature" in result.columns
|
|
132
|
+
assert "precipitation" in result.columns
|
|
133
|
+
# Filtering
|
|
134
|
+
result = ctx.sql(
|
|
135
|
+
"SELECT * FROM weather WHERE temperature > 10 LIMIT 50"
|
|
136
|
+
).to_pandas()
|
|
137
|
+
assert len(result) > 0
|
|
138
|
+
assert (result["temperature"] > 10).all()
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def test_synthetic_aggregations(synthetic_dataset):
|
|
142
|
+
ctx = XarrayContext()
|
|
143
|
+
ctx.from_dataset("synthetic", synthetic_dataset)
|
|
144
|
+
# COUNT aggregation
|
|
145
|
+
result = ctx.sql("SELECT COUNT(*) AS total_count FROM synthetic").to_pandas()
|
|
146
|
+
assert result["total_count"].iloc[0] > 0
|
|
147
|
+
# MIN, MAX, AVG
|
|
148
|
+
query = """
|
|
149
|
+
SELECT MIN(temperature) AS min_temp,
|
|
150
|
+
MAX(temperature) AS max_temp,
|
|
151
|
+
AVG(temperature) AS avg_temp
|
|
152
|
+
FROM synthetic
|
|
153
|
+
"""
|
|
154
|
+
result = ctx.sql(query).to_pandas()
|
|
155
|
+
assert result["min_temp"].iloc[0] < result["max_temp"].iloc[0]
|
|
156
|
+
assert (
|
|
157
|
+
result["min_temp"].iloc[0]
|
|
158
|
+
<= result["avg_temp"].iloc[0]
|
|
159
|
+
<= result["max_temp"].iloc[0]
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def test_invalid_table_name(air_dataset_small):
|
|
164
|
+
ctx = XarrayContext()
|
|
165
|
+
ctx.from_dataset("air", air_dataset_small)
|
|
166
|
+
with pytest.raises(Exception):
|
|
167
|
+
ctx.sql("SELECT * FROM nonexistent_table")
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def test_invalid_column_name(air_dataset_small):
|
|
171
|
+
ctx = XarrayContext()
|
|
172
|
+
ctx.from_dataset("air", air_dataset_small)
|
|
173
|
+
with pytest.raises(Exception):
|
|
174
|
+
ctx.sql("SELECT nonexistent_column FROM air")
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def test_sql_syntax_error(air_dataset_small):
|
|
178
|
+
ctx = XarrayContext()
|
|
179
|
+
ctx.from_dataset("air", air_dataset_small)
|
|
180
|
+
with pytest.raises(Exception):
|
|
181
|
+
ctx.sql("SELECT * FORM air") # Typo: FORM instead of FROM
|
|
182
|
+
with pytest.raises(Exception):
|
|
183
|
+
ctx.sql("SELECT * FROM air WHERE") # Incomplete WHERE
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def test_cross_join(air_and_stations):
|
|
187
|
+
air, stations = air_and_stations
|
|
188
|
+
ctx = XarrayContext()
|
|
189
|
+
ctx.from_dataset("air_data", air)
|
|
190
|
+
ctx.from_dataset("stations", stations)
|
|
191
|
+
result = ctx.sql(
|
|
192
|
+
"SELECT COUNT(*) AS total FROM air_data CROSS JOIN stations"
|
|
193
|
+
).to_pandas()
|
|
194
|
+
assert result["total"].iloc[0] > 0
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: xarray_sql
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Classifier: Development Status :: 4 - Beta
|
|
5
|
+
Classifier: Intended Audience :: Science/Research
|
|
6
|
+
Classifier: Intended Audience :: Developers
|
|
7
|
+
Classifier: Intended Audience :: Information Technology
|
|
8
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
9
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
10
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
11
|
+
Classifier: Operating System :: POSIX
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Rust
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
|
|
18
|
+
Classifier: Topic :: Database :: Front-Ends
|
|
19
|
+
Requires-Dist: dask>=2024.8.0
|
|
20
|
+
Requires-Dist: datafusion==51.0.0
|
|
21
|
+
Requires-Dist: xarray>=2024.7.0
|
|
22
|
+
Requires-Dist: pytest ; extra == 'test'
|
|
23
|
+
Requires-Dist: xarray[io] ; extra == 'test'
|
|
24
|
+
Requires-Dist: gcsfs ; extra == 'test'
|
|
25
|
+
Provides-Extra: test
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Summary: Querry Xarray with SQL.
|
|
28
|
+
Author-email: Alexander Merose <al@merose.com>
|
|
29
|
+
License: Apache-2.0
|
|
30
|
+
Requires-Python: >=3.10
|
|
31
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
32
|
+
Project-URL: Homepage, https://github.com/alxmrs/xarray-sql
|
|
33
|
+
Project-URL: Issues, https://github.com/alxmrs/xarray-sql/issues
|
|
34
|
+
|
|
35
|
+
# xarray-sql
|
|
36
|
+
|
|
37
|
+
_Query [Xarray](https://xarray.dev/) with SQL_
|
|
38
|
+
|
|
39
|
+
[](https://github.com/alxmrs/xarray-sql/actions/workflows/ci.yml)
|
|
40
|
+
[](https://github.com/alxmrs/xarray-sql/actions/workflows/lint.yml)
|
|
41
|
+
[](https://github.com/alxmrs/xarray-sql/actions/workflows/ci-build.yml)
|
|
42
|
+
[](https://github.com/alxmrs/xarray-sql/actions/workflows/ci-rust.yml)
|
|
43
|
+
|
|
44
|
+
```shell
|
|
45
|
+
pip install xarray-sql
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## What is this?
|
|
49
|
+
|
|
50
|
+
This is an experiment to provide a SQL interface for array datasets.
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
import xarray as xr
|
|
54
|
+
import xarray_sql as xql
|
|
55
|
+
|
|
56
|
+
ds = xr.tutorial.open_dataset('air_temperature')
|
|
57
|
+
|
|
58
|
+
# The same as a dask-sql Context; i.e. an Apache DataFusion Context.
|
|
59
|
+
ctx = xql.XarrayContext()
|
|
60
|
+
ctx.from_dataset('air', ds, chunks=dict(time=24)) # the dataset needs to be chunked!
|
|
61
|
+
# data is only materialized when we make a query.
|
|
62
|
+
|
|
63
|
+
result = ctx.sql('''
|
|
64
|
+
SELECT
|
|
65
|
+
"lat", "lon", AVG("air") as air_avg
|
|
66
|
+
FROM
|
|
67
|
+
"air"
|
|
68
|
+
GROUP BY
|
|
69
|
+
"lat", "lon"
|
|
70
|
+
''')
|
|
71
|
+
# DataFrame()
|
|
72
|
+
# +------+-------+--------------------+
|
|
73
|
+
# | lat | lon | air_avg |
|
|
74
|
+
# +------+-------+--------------------+
|
|
75
|
+
# | 75.0 | 205.0 | 259.88662671232834 |
|
|
76
|
+
# | 75.0 | 207.5 | 259.48268150684896 |
|
|
77
|
+
# | 75.0 | 230.0 | 258.9192123287667 |
|
|
78
|
+
# | 75.0 | 275.0 | 257.07574315068456 |
|
|
79
|
+
# | 75.0 | 322.5 | 250.11792123287654 |
|
|
80
|
+
# | 75.0 | 325.0 | 250.81590068493134 |
|
|
81
|
+
# | 72.5 | 205.0 | 262.74933904109537 |
|
|
82
|
+
# | 72.5 | 207.5 | 262.5384315068488 |
|
|
83
|
+
# | 72.5 | 230.0 | 260.82879452054743 |
|
|
84
|
+
# | 72.5 | 275.0 | 257.3063321917804 |
|
|
85
|
+
# +------+-------+--------------------+
|
|
86
|
+
# Data truncated.
|
|
87
|
+
|
|
88
|
+
# The full query is only made when we call `collect()`, or, in this case,
|
|
89
|
+
# `to_pandas()`.
|
|
90
|
+
df = result.to_pandas()
|
|
91
|
+
df.head()
|
|
92
|
+
# lat lon air_avg
|
|
93
|
+
# 0 75.0 232.5 258.836188
|
|
94
|
+
# 1 75.0 247.5 257.716171
|
|
95
|
+
# 2 75.0 262.5 257.347959
|
|
96
|
+
# 3 75.0 277.5 257.671308
|
|
97
|
+
# 4 72.5 232.5 260.654401
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Succinctly, we "pivot" Xarray Datasets (with consistent dimensions) to treat them like tables so we can run
|
|
101
|
+
SQL queries against them.
|
|
102
|
+
|
|
103
|
+
## Why build this?
|
|
104
|
+
|
|
105
|
+
A few reasons:
|
|
106
|
+
|
|
107
|
+
* Even though SQL is the lingua franca of data, scientific datasets are often
|
|
108
|
+
inaccessible to non-scientists (SQL users).
|
|
109
|
+
* Joining tabular data with raster data is common yet difficult. It could be
|
|
110
|
+
easy.
|
|
111
|
+
* There are many cloud-native, Xarray-openable datasets,
|
|
112
|
+
from [Google Earth Engine](https://github.com/google/Xee)
|
|
113
|
+
to the [Source Cooperative](https://source.coop/products?tags=zarr). Wouldn’t it be great if these
|
|
114
|
+
were also SQL-accessible? How can the bridge be built with minimal effort?
|
|
115
|
+
|
|
116
|
+
This is a light-weight way to prove the value of the interface.
|
|
117
|
+
|
|
118
|
+
The larger goal is to explore the hypothesis that the [Pangeo
|
|
119
|
+
ecosystem is a scientific database](https://www.hytradboi.com/2025/c18b8cdc-fd17-4099-9c03-eb107217f627-pangeo-is-a-database). Here, xarray-sql can be thought of as a missing
|
|
120
|
+
DB front end.
|
|
121
|
+
|
|
122
|
+
## How does it work?
|
|
123
|
+
|
|
124
|
+
All chunks in a Xarray Dataset are transformed into a Dask DataFrame via
|
|
125
|
+
`from_map()` and `to_dataframe()`. For SQL support, we just use `dask-sql`.
|
|
126
|
+
That's it!
|
|
127
|
+
|
|
128
|
+
_2025 update_: This library now implements a Dask-like `from_map` interface in
|
|
129
|
+
pure DataFusion and PyArrow, but works with the same principle!
|
|
130
|
+
|
|
131
|
+
_2026 update_: Instead of `from_map()`, we make factory functions from blocks of
|
|
132
|
+
Xarray datasets that return RecordBatchReaders. These feed into a Rust-based
|
|
133
|
+
DataFusion `TableProvider`. Every chunk is uses the Arrow in memory format to
|
|
134
|
+
translate between Python and Rust. Even still, the core of what makes this idea
|
|
135
|
+
work is the core `pivot()` operation from where this project began!
|
|
136
|
+
|
|
137
|
+
## Why does this work?
|
|
138
|
+
|
|
139
|
+
Underneath Xarray, Dask, and Pandas, there are NumPy arrays. These are paged in
|
|
140
|
+
chunks and represented contiguously in memory. It is only a matter of metadata
|
|
141
|
+
that breaks them up into ndarrays. `pivot()`, which uses `to_dataframe()`,
|
|
142
|
+
just changes this metadata (via a `ravel()`/`reshape()`), back into a column
|
|
143
|
+
amenable to a DataFrame. We take advantage of this light weight metadata change to
|
|
144
|
+
make chunked information scannable by a DB engine (DataFusion).
|
|
145
|
+
|
|
146
|
+
## What are the current limitations?
|
|
147
|
+
|
|
148
|
+
TBD, DataFusion provides a whole new world! Currently, we're looking for
|
|
149
|
+
early users – "tire kickers", if you will. We'd love your input to shape the direction of this
|
|
150
|
+
project! Please, give this a try and [file issues](https://github.com/alxmrs/xarray-sql/issues) as
|
|
151
|
+
you see fit. Check out our [contributing guide](CONTRIBUTING.md), too 😉.
|
|
152
|
+
|
|
153
|
+
I can say that for now, the library is oriented towards making whole scans of
|
|
154
|
+
Xarray Datasets. Common filter optimizations (even basic ones like an `.sel()` on
|
|
155
|
+
core dimensions, let alone predicate push downs) are not fully implemented yet.
|
|
156
|
+
However, these operations and more are on our roadmap.
|
|
157
|
+
|
|
158
|
+
## What would a deeper integration look like?
|
|
159
|
+
|
|
160
|
+
I have a few ideas so far. One approach involves applying operations directly on
|
|
161
|
+
Xarray Datasets. This approach is being pursued
|
|
162
|
+
[here](https://github.com/google/weather-tools/tree/main/xql), as `xql`.
|
|
163
|
+
|
|
164
|
+
Deeper still: I was thinking we could make
|
|
165
|
+
a [virtual](https://fsspec.github.io/kerchunk/)
|
|
166
|
+
filesystem for parquet that would internally map to Zarr. Raster-backed virtual
|
|
167
|
+
parquet would open up integrations to numerous tools like dask, pyarrow, duckdb,
|
|
168
|
+
and BigQuery. More thoughts on this
|
|
169
|
+
in [#4](https://github.com/alxmrs/xarray-sql/issues/4).
|
|
170
|
+
|
|
171
|
+
_2025 update_: Something like this is being built across a few projects! The ones I know about are:
|
|
172
|
+
- [CartoDB's Raquet](https://github.com/CartoDB/raquet)
|
|
173
|
+
- The DataFusion community's [arrow-zarr](https://github.com/datafusion-contrib/arrow-zarr)
|
|
174
|
+
|
|
175
|
+
As of writing, this project is [amid integrating](https://github.com/alxmrs/xarray-sql/pull/69) a
|
|
176
|
+
rust-based DataFusion backend provided by arrow-zarr.
|
|
177
|
+
|
|
178
|
+
## Roadmap
|
|
179
|
+
|
|
180
|
+
- [x] ~Lazy evaluation via the pyarrow Dataset interface [#93](https://github.com/alxmrs/xarray-sql/issues/93).~ _Implemented in [#100](https://github.com/alxmrs/xarray-sql/pull/100)_
|
|
181
|
+
- [ ] Support proper parallelism via proper partition handling on the rust/datafusion side. [#106](https://github.com/alxmrs/xarray-sql/issues/106)
|
|
182
|
+
- [ ] Support core datafusion optimizations to scan less data, like [104](https://github.com/alxmrs/xarray-sql/issues/104), ...
|
|
183
|
+
- [ ] Translate a single Zarr to a collection of tables via DataFusion's catalog interface [#85](https://github.com/alxmrs/xarray-sql/issues/85).
|
|
184
|
+
- [ ] Distributed beyond a single node through the DataFusion integration with Ray Datasets [#68](https://github.com/alxmrs/xarray-sql/issues/68) or Apache Ballista [#98](https://github.com/alxmrs/xarray-sql/issues/98).
|
|
185
|
+
- [ ] Demo: calculate Sea Surface Temperature from 1940 - Present in SQL [#36](https://github.com/alxmrs/xarray-sql/issues/36).
|
|
186
|
+
- [ ] Provide an option to integrate DataFusion directly to Zarr via Rust [#4](https://github.com/alxmrs/xarray-sql/issues/4).
|
|
187
|
+
- [ ] (To be formally announced eventually): The 100 Trillion Row Challenge [#34](https://github.com/alxmrs/xarray-sql/issues/34).
|
|
188
|
+
|
|
189
|
+
## Sponsors & Contributors
|
|
190
|
+
|
|
191
|
+
I want to give a special thanks to the following folks and institutions:
|
|
192
|
+
|
|
193
|
+
- Pramod Gupta and the Anthromet Team at Google Research for the problem
|
|
194
|
+
formation and design inspiration.
|
|
195
|
+
- Jake Wall and AI2/Ecoscope for compute resources and key use cases.
|
|
196
|
+
- Charles Stern, Stephan Hoyer, Alexander Kmoch, Wei Ji, and Qiusheng Wu
|
|
197
|
+
for the early review and discussion of this project.
|
|
198
|
+
- Tom Nichols, Kyle Barron, Tom White, and Maxime Dion for the [Array Working
|
|
199
|
+
Group](https://discourse.pangeo.io/t/new-working-group-for-distributed-array-computing/2734)
|
|
200
|
+
and DataFusion-specific collaboration.
|
|
201
|
+
- The gracious volunteer data science students at [UCSD's DS3](https://www.ds3atucsd.com/) org,
|
|
202
|
+
who are working to make this library better.
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
## License
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
Copyright 2024 Alexander Merose
|
|
209
|
+
|
|
210
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
211
|
+
you may not use this file except in compliance with the License.
|
|
212
|
+
You may obtain a copy of the License at
|
|
213
|
+
|
|
214
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
215
|
+
|
|
216
|
+
Unless required by applicable law or agreed to in writing, software
|
|
217
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
218
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
219
|
+
See the License for the specific language governing permissions and
|
|
220
|
+
limitations under the License.
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
All vendored code has proper license attribution.
|
|
224
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
xarray_sql\__init__.py,sha256=ygvqrOXoVB6w2PMQWia4gssWqrrbNi_iBWodzD4csgs,227
|
|
2
|
+
xarray_sql\_native.cp311-win_amd64.pyd,sha256=3y7HBdjlyrAhragmKYStC2VZG3jMF00G4GXo98YobOM,89384960
|
|
3
|
+
xarray_sql\core.py,sha256=sHZvRIkr8moHhjJtSp3I_-SgS683K8euODsDW0dWMD8,1261
|
|
4
|
+
xarray_sql\df.py,sha256=EvPHWM3RNkqUS5SaNSSbVEB-tRok1OiI2NNojTQwzpM,5539
|
|
5
|
+
xarray_sql\df_test.py,sha256=3z-1qhPJCOEOgv0SF2kHXVKARfJqcuEPejC_yjz40Ww,9902
|
|
6
|
+
xarray_sql\reader.py,sha256=U6HosDEwhHbG_oXkb1tpjuDzBxYKa9DWRo06hF5gN_g,9122
|
|
7
|
+
xarray_sql\reader_test.py,sha256=78-vxODwGAIclDHh92FlxMUhE5F-7vxZjwtqqyqzNv0,30666
|
|
8
|
+
xarray_sql\sql.py,sha256=nxD7CDA7HP7Zj5h3jGM8DeOoSGGWclAw8uzh-ZuHFl4,468
|
|
9
|
+
xarray_sql\sql_test.py,sha256=G85o7MEnz5R_c_1PejXoL66URDGhJMMjduJx2vwUGDY,5697
|
|
10
|
+
xarray_sql-0.2.0.dist-info\METADATA,sha256=6ok0RLEuk23pYxBZZj7TpP0zwo2KXbJcrBS5ca32I4M,10222
|
|
11
|
+
xarray_sql-0.2.0.dist-info\WHEEL,sha256=X79LywvMB9iCuFHu88xBAFTJDhRqJi6Yh9hhoCI9jao,97
|
|
12
|
+
xarray_sql-0.2.0.dist-info\licenses\LICENSE,sha256=Pd-b5cKP4n2tFDpdx27qJSIq0d1ok0oEcGTlbtL6QMU,11560
|
|
13
|
+
xarray_sql-0.2.0.dist-info\RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|