Skip to content

Commit 33ebf06

Browse files
authored
Adding back in lazy xr.Dataset and metadata parsing fix. (#94)
1 parent fa436e8 commit 33ebf06

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

xarray_sql/df.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,15 @@ def read_xarray(ds: xr.Dataset, chunks: Chunks = None) -> pa.RecordBatchReader:
183183
Returns:
184184
A PyArrow Table, which is a table representation of the input Dataset.
185185
"""
186-
fst = next(iter(ds.values())).dims
187-
assert all(
188-
da.dims == fst for da in ds.values()
189-
), "All dimensions must be equal. Please filter data_vars in the Dataset."
190-
191-
blocks = list(block_slices(ds, chunks))
192186

193187
def pivot_block(b: Block):
194188
return pivot(ds.isel(b))
195189

196-
schema = pa.Schema.from_pandas(pivot_block(blocks[0]))
197-
last_schema = pa.Schema.from_pandas(pivot_block(blocks[-1]))
198-
assert schema == last_schema, "Schemas must be consistent across blocks!"
190+
fst = next(iter(ds.values())).dims
191+
assert all(
192+
da.dims == fst for da in ds.values()
193+
), "All dimensions must be equal. Please filter data_vars in the Dataset."
199194

195+
schema = _parse_schema(ds)
196+
blocks = block_slices(ds, chunks)
200197
return from_map_batched(pivot_block, blocks, schema=schema)

0 commit comments

Comments
 (0)