-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Arrow PyCapsule Interface #2504
Comments
Very cool. I was just chatting with @paleolimbot about whether Daft could remove its dependency on PyArrow at some point and rely on something lighter-weight to do import/export of arrow data. Today it's technically possible (we can have PyArrow as an optional dependency for the most part, except for some file writing code where we still rely on PyArrow utilities), but definitely requiring PyArrow at all on the critical path is a heavy dependency. If I understand correctly, there are a few issues to be fixed here:
Am I understanding this correctly? |
I think so! An example of the import side: On the export side, you probably want to emulate https://github.com/kylebarron/arro3/blob/227c505714865064389d626c7fe3d79e8bd315c0/pyo3-arrow/src/array.rs#L123-L141 (or something like it using arrow2/the stream, like maybe pola-rs/r-polars#5 ). I hope that helps! |
In case it's useful, I implemented the pycapsule interface for polars in pola-rs/polars#17676 and pola-rs/polars#17693. I figure polars-arrow hasn't diverged too much from arrow2, so it should be pretty similar to implement the pycapsule interface in daft. |
Is your feature request related to a problem? Please describe.
The Arrow PyCapsule Interface is a new spec to simplify Arrow interop between compiled Python libraries.
For example, you have a
daft.from_arrow
method but this narrowly allows only pyarrow Table objectsDaft/daft/table/table.py
Lines 102 to 104 in a5badb4
pyarrow.RecordBatchReader
or any non-pyarrow Arrow objects, and requires a pyarrow dependency, which is quite large.A
from_arrow
method that looks for the__arrow_c_stream__
method would work out of the box on any Arrow-based Python library implementing this spec. That includes:Table
s andRecordBatchReader
sibis.Table
objects ibis-project/ibis#9143)and hopefully soon duckdb and polars objects as well (pola-rs/polars#12530).
Implementing the pycapsule interface on daft classes means that any of those other libraries would just work on daft classes.
Describe the solution you'd like
Describe alternatives you've considered
Additional context
I've implemented import and export of the pycapsule interface for
arrow
objects in pyo3-arrow (in a separate crate for a few reasons).It looks like daft is still tied to arrow2, but maybe pyo3-arrow is useful as a reference here.
The text was updated successfully, but these errors were encountered: