Skip to content

Add from_apache_arrow / from_polars bridges and try_* fallible siblings#70

Merged
pbower merged 1 commit into
mainfrom
polars_arrow_incoming
May 11, 2026
Merged

Add from_apache_arrow / from_polars bridges and try_* fallible siblings#70
pbower merged 1 commit into
mainfrom
polars_arrow_incoming

Conversation

@pbower
Copy link
Copy Markdown
Owner

@pbower pbower commented May 11, 2026

Mirrors the existing to_* API across Array, FieldArray, Table, SuperArray,
and SuperTable. Each panicking method has a try_* sibling returning
Result<_, MinarrowError>. Adds From<&Series>, From<&RecordBatch>,
From<&DataFrame> for .into() ergonomics.

New MinarrowError::BridgeError variant carries arrow-rs / polars FFI
failures, with feature-gated From impls for ArrowError and PolarsError.

Breaking changes:
- Removes Array::to_apache_arrow_with_field and Array::to_polars_with_field. Wrap in FieldArray and call its to_*() method when an explicit Field is needed.
- Renames SuperArray::to_apache_arrow_chunks and SuperTable::to_apache_arrow_batches to to_apache_arrow for symmetry across the bridge API. Return types disambiguate the shape.

Also fixes a per-call Box leak in the existing to_* paths where the
ArrowArray/ArrowSchema heap wrappers were not freed after read().

Closes #65

@pbower pbower force-pushed the polars_arrow_incoming branch 2 times, most recently from ab78f62 to 2869611 Compare May 11, 2026 23:02
Adds symmetric from_* import API across Array, FieldArray, Table,
SuperArray, and SuperTable. Each panicking method has a try_* sibling
returning Result<_, MinarrowError>. Adds From<&Series>, From<&RecordBatch>,
From<&DataFrame>, From<&[RecordBatch]> for .into() ergonomics.

Bridge logic between Minarrow's C Data Interface and arrow-rs / polars
is now centralised in two new feature-gated modules:
  - src/ffi/arrow_rs.rs  (cast_arrow)
  - src/ffi/polars.rs    (cast_polars)
Each exposes an export / import pair built on the existing
arrow_c_ffi::export_to_c and import_from_c_owned primitives.

New MinarrowError::BridgeError variant carries arrow-rs / polars FFI
failures, with feature-gated From impls for ArrowError and PolarsError.

Breaking changes:
  - Removes Array::to_apache_arrow_with_field and
    Array::to_polars_with_field. Wrap in FieldArray and call its to_*()
    method when an explicit Field is needed.
  - Renames SuperArray::to_apache_arrow_chunks and
    SuperTable::to_apache_arrow_batches to to_apache_arrow for symmetry
    across the bridge API. Return types disambiguate the shape.

Also fixes a per-call Box leak in the existing to_* paths where the
ArrowArray/ArrowSchema heap wrappers were not freed after read().
@pbower pbower force-pushed the polars_arrow_incoming branch from 2869611 to 133669e Compare May 11, 2026 23:06
@pbower pbower merged commit 49f3201 into main May 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

import data from polars (rust)

1 participant