genemerewether opened a new issue, #377: URL: https://github.com/apache/arrow-nanoarrow/issues/377
Hi - it is nice to have a way to get pyarrow tables into c++ via nanoarrow and pybind - is this an officially supported use case? I have lingering questions about the ownership semantics here. Am I ok as long as the pyarrow table doesn't get deleted / garbage collected and I don't hold the nanoarrow table past the duration of the call? This might be worth calling out as an advantage of nanoarrow - I've found this code very portable across compilers / versions, especially compared to `pybind`-ing `arrow` C++ package. https://arrow.apache.org/docs/format/CDataInterface/PyCapsuleInterface.html#arrow-pycapsule-interface Python: ``` n_legs = pa.array([2, 4, 5, 100]) animals = pa.array(["Flamingo", "Horse", "Brittle stars", "Centipede"]) names = ["n_legs", "animals"] t = pa.Table.from_arrays([n_legs, animals], names=names) parse_pyarrow_table(*t.to_batches()[0].__arrow_c_array__()) ``` `pybind` method: ``` m.def("parse_pyarrow_table", [](const pybind11::capsule& schema_capsule, const pybind11::capsule& array_capsule) { LOG(INFO) << array_capsule.name() << "; " << schema_capsule.name(); nanoarrow::UniqueArray array(static_cast<ArrowArray*>(array_capsule.get_pointer())); nanoarrow::UniqueSchema schema(static_cast<ArrowSchema*>(schema_capsule.get_pointer())); ... ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
