Skip to content

Commit

Permalink
Export list and struct array constructors (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron authored Jul 26, 2024
1 parent 264f20f commit e584d0d
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 6 deletions.
6 changes: 6 additions & 0 deletions arro3-core/python/arro3/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
RecordBatchReader,
Schema,
Table,
fixed_size_list_array,
list_array,
struct_array,
___version, # noqa,
)

Expand All @@ -23,4 +26,7 @@
"RecordBatchReader",
"Schema",
"Table",
"fixed_size_list_array",
"list_array",
"struct_array",
)
49 changes: 49 additions & 0 deletions arro3-core/python/arro3/core/_rust.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -591,3 +591,52 @@ class Table:
Returns:
_description_
"""

def fixed_size_list_array(
values: ArrowArrayExportable,
list_size: int,
*,
type: ArrowSchemaExportable | None = None,
) -> Array:
"""_summary_
Args:
values: _description_
list_size: _description_
type: _description_. Defaults to None.
Returns:
_description_
"""

def list_array(
offsets: ArrowArrayExportable,
values: ArrowArrayExportable,
*,
type: ArrowSchemaExportable | None = None,
) -> Array:
"""_summary_
Args:
offsets: _description_
values: _description_
type: _description_. Defaults to None.
Returns:
_description_
"""

def struct_array(
arrays: Sequence[ArrowArrayExportable],
*,
fields: Sequence[ArrowSchemaExportable],
) -> Array:
"""_summary_
Args:
arrays: _description_
fields: _description_
Returns:
_description_
"""
13 changes: 7 additions & 6 deletions arro3-core/src/constructors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use pyo3_arrow::{PyArray, PyField};

#[pyfunction]
#[pyo3(signature=(values, list_size, *, r#type=None))]
#[allow(dead_code)]
fn fixed_size_list_array(
pub(crate) fn fixed_size_list_array(
py: Python,
values: PyArray,
list_size: i32,
Expand All @@ -36,8 +35,7 @@ fn fixed_size_list_array(

#[pyfunction]
#[pyo3(signature=(offsets, values, *, r#type=None))]
#[allow(dead_code)]
fn list_array(
pub(crate) fn list_array(
py: Python,
offsets: PyArray,
values: PyArray,
Expand Down Expand Up @@ -82,8 +80,11 @@ fn list_array(

#[pyfunction]
#[pyo3(signature=(arrays, *, fields))]
#[allow(dead_code)]
fn struct_array(py: Python, arrays: Vec<PyArray>, fields: Vec<PyField>) -> PyArrowResult<PyObject> {
pub(crate) fn struct_array(
py: Python,
arrays: Vec<PyArray>,
fields: Vec<PyField>,
) -> PyArrowResult<PyObject> {
let arrays = arrays
.into_iter()
.map(|arr| {
Expand Down
4 changes: 4 additions & 0 deletions arro3-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@ fn _rust(_py: Python, m: &Bound<PyModule>) -> PyResult<()> {
m.add_class::<pyo3_arrow::PySchema>()?;
m.add_class::<pyo3_arrow::PyTable>()?;

m.add_wrapped(wrap_pyfunction!(constructors::fixed_size_list_array))?;
m.add_wrapped(wrap_pyfunction!(constructors::list_array))?;
m.add_wrapped(wrap_pyfunction!(constructors::struct_array))?;

Ok(())
}

0 comments on commit e584d0d

Please sign in to comment.