Skip to content

Conversation

@alxmrs
Copy link
Owner

@alxmrs alxmrs commented Jan 16, 2026

TODO(alxmrs): merge into #100.

alxmrs and others added 4 commits January 15, 2026 17:42
…rom arrow streams, which are lazy, to implement the table registration, which in the default df library, is not lazy enough.
…(XarrayContext). This leads to two failed tests, but this could be caused by test errors.
The previous implementation stored a single Arrow stream that could only
be consumed once, causing subsequent queries on the same table to return
empty results. This broke filters and aggregations.

Changes:
- Modify Rust PyArrowStreamPartition to accept a factory function instead
  of a stream object. The factory is called on each execute() to create
  a fresh stream, allowing multiple queries on the same table.
- Update LazyArrowStreamTable to take a factory and schema instead of
  consuming a stream directly.
- Update Python read_xarray_table to create a factory function that
  produces fresh XarrayRecordBatchReader instances.
- Update tests to use the new factory-based API via read_xarray_table.

This enables proper lazy evaluation while supporting multiple queries
on registered tables, fixing the failing filter and aggregation tests.
reader = XarrayRecordBatchReader(
ds, chunks, _iteration_callback=_iteration_callback
)
return pa.RecordBatchReader.from_stream(reader)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we do this? Can't we just return the custom stream class?

XarrayRecordBatchReader already implements __arrow_c_stream__, so there's
no need to wrap it in pa.RecordBatchReader.from_stream(). The Rust code
can consume it directly via ArrowArrayStreamReader::from_pyarrow_bound.
@alxmrs
Copy link
Owner Author

alxmrs commented Jan 18, 2026

Integrating into #100.

@alxmrs alxmrs closed this Jan 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants