Skip to content
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

Export list and struct array constructors #71

Merged
merged 3 commits into from
Jul 26, 2024
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
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(())
}