Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ numpy = "0.28"
object_store = "0.13"
parquet = "59"
pyo3 = { version = "0.28", features = ["macros", "indexmap"] }
pyo3-arrow = { path = "pyo3-arrow" }
# pyo3-arrow = { path = "pyo3-arrow" }
pyo3-arrow = { git = "https://github.com/kylebarron/arro3", rev = "7cfe579bab03406bf5d3e4824e171bf7204b43cc" }
pyo3-async-runtimes = { version = "0.28", features = ["tokio-runtime"] }
pyo3-file = { git = "https://github.com/kylebarron/pyo3-file", rev = "f724ceaa7e06e7d227bf40b1d60adbb842963a44" }
pyo3-object_store = "0.9"
Expand Down
25 changes: 12 additions & 13 deletions pyo3-arrow/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyo3-arrow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ arrow-schema = "59"
arrow-select = "59"
chrono = "0.4"
chrono-tz = "0.10"
pyo3 = { version = "0.28", features = ["chrono", "chrono-tz", "indexmap"] }
pyo3 = { version = "0.29", features = ["chrono", "chrono-tz", "indexmap"] }
half = "2"
indexmap = "2"
numpy = { version = "0.28", features = ["half"] }
numpy = { version = "0.29", features = ["half"] }
thiserror = "1"

[lib]
Expand Down
23 changes: 13 additions & 10 deletions pyo3-arrow/src/ffi/to_python/utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::ffi::CString;
use std::ffi::CStr;
use std::sync::Arc;

use arrow_array::ffi::{FFI_ArrowArray, FFI_ArrowSchema};
Expand All @@ -13,15 +13,18 @@ use crate::ffi::from_python::utils::import_schema_pycapsule;
use crate::ffi::to_python::ffi_stream::new_stream;
use crate::ffi::{ArrayIterator, ArrayReader};

const ARRAY_CAPSULE_NAME: &CStr = c"arrow_array";
const SCHEMA_CAPSULE_NAME: &CStr = c"arrow_schema";
const STREAM_CAPSULE_NAME: &CStr = c"arrow_array_stream";

/// Export a [`arrow_schema::Schema`], [`arrow_schema::Field`], or [`arrow_schema::DataType`] to a
/// PyCapsule holding an Arrow C Schema pointer.
pub fn to_schema_pycapsule(
py: Python,
field: impl TryInto<FFI_ArrowSchema, Error = ArrowError>,
) -> PyArrowResult<Bound<PyCapsule>> {
let ffi_schema: FFI_ArrowSchema = field.try_into()?;
let schema_capsule_name = CString::new("arrow_schema").unwrap();
let schema_capsule = PyCapsule::new(py, ffi_schema, Some(schema_capsule_name))?;
let schema_capsule = PyCapsule::new_with_value(py, ffi_schema, SCHEMA_CAPSULE_NAME)?;
Ok(schema_capsule)
}

Expand Down Expand Up @@ -53,11 +56,8 @@ pub fn to_array_pycapsules<'py>(
let ffi_schema = FFI_ArrowSchema::try_from(&field)?;
let ffi_array = FFI_ArrowArray::new(&array_data);

let schema_capsule_name = CString::new("arrow_schema").unwrap();
let array_capsule_name = CString::new("arrow_array").unwrap();

let schema_capsule = PyCapsule::new(py, ffi_schema, Some(schema_capsule_name))?;
let array_capsule = PyCapsule::new(py, ffi_array, Some(array_capsule_name))?;
let schema_capsule = PyCapsule::new_with_value(py, ffi_schema, SCHEMA_CAPSULE_NAME)?;
let array_capsule = PyCapsule::new_with_value(py, ffi_array, ARRAY_CAPSULE_NAME)?;
let tuple = PyTuple::new(py, vec![schema_capsule, array_capsule])?;

Ok(tuple)
Expand Down Expand Up @@ -89,6 +89,9 @@ pub fn to_stream_pycapsule<'py>(
}

let ffi_stream = new_stream(array_reader);
let stream_capsule_name = CString::new("arrow_array_stream").unwrap();
Ok(PyCapsule::new(py, ffi_stream, Some(stream_capsule_name))?)
Ok(PyCapsule::new_with_value(
py,
ffi_stream,
STREAM_CAPSULE_NAME,
)?)
}
Loading