-
Notifications
You must be signed in to change notification settings - Fork 18
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
Read Arrow C Stream from Arrow PyCapsule Interface #501
Changes from all commits
0c39d5d
3db45e0
9014157
98aae9c
d690caa
26340fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -34,9 +34,10 @@ use { | |||||||
use { | ||||||||
arrow::pyarrow::{FromPyArrow, ToPyArrow}, | ||||||||
pyo3::{ | ||||||||
conversion::FromPyObjectBound, | ||||||||
prelude::*, | ||||||||
types::{PyList, PyTuple}, | ||||||||
Bound, PyAny, PyErr, PyObject, Python, | ||||||||
Bound, PyAny, PyErr, PyObject, PyResult, Python, | ||||||||
}, | ||||||||
}; | ||||||||
|
||||||||
|
@@ -271,6 +272,13 @@ impl VegaFusionTable { | |||||||
} | ||||||||
} | ||||||||
|
||||||||
#[cfg(feature = "pyarrow")] | ||||||||
pub fn from_arrow_c_stream(table: &Bound<PyAny>) -> PyResult<Self> { | ||||||||
let pytable = pyo3_arrow::PyTable::from_py_object_bound(table.as_borrowed())?; | ||||||||
Comment on lines
+276
to
+277
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you keep this method the same to only support
Suggested change
|
||||||||
let (batches, schema) = pytable.into_inner(); | ||||||||
Ok(VegaFusionTable::try_new(schema, batches)?) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I never know whether |
||||||||
} | ||||||||
|
||||||||
#[cfg(feature = "pyarrow")] | ||||||||
pub fn from_pyarrow(pyarrow_table: &Bound<PyAny>) -> std::result::Result<Self, PyErr> { | ||||||||
// Extract table.schema as a Rust Schema | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a public API or is this an internal API called by your Python code? If it's a public API, it might be preferred to overload the existing
from_pyarrow
method.You can check for both the pycapsule interface and fall back to pyarrow in a single method. That's a recommended approach here.
You can do this by first trying to extract a
PyTable
; this will work for any recent pyarrow table object (or pyarrow record batch reader). And then you can fallback to your existingfrom_pyarrow
code.