Skip to content

Hold the Rust structs in Arrow tables, by arrow-rs - #27

Merged
nickyoung-github merged 1 commit into
masterfrom
feature/rust-arrow
Nov 29, 2026
Merged

nickyoung-github merged 1 commit into
masterfrom
feature/rust-arrow

Conversation

@nickyoung-github

Copy link
Copy Markdown
Owner

The generated Rust structs are held in Arrow tables, and read from them, by arrow-rs: as ARROW_FORMAT.md has it, which Python and C++ hold and read.

  • With the crate's feature arrow, dataclass_native::arrow::{to_arrow, from_arrow} make and read a RecordBatch of the objects, and one of each class they may share: which the rest of Rust's Arrow takes.
  • Of arrow-rs's crates for arrays alone, and of one major version, 59, as the arrays of two do not mix. The crate still depends on nothing without the feature.
  • The generated code says what each struct, enum and union is by the crate's macros arrow_struct!, arrow_enum! and arrow_union!, which are of nothing without the feature. Each type has a builder of its column and a reader of one, of its own type: nothing is found by name or cast as each row is held or read.
  • An extension holds its classes in Arrow only if its crate has a feature arrow, which is ["dataclass_native/arrow"], and is built with it: as arrow-rs is much to build. Python holds them otherwise, as before.
  • Tables go to and from Python as the capsules of the Arrow PyCapsule interface, which the extension makes itself, as that of C++ does: not by a crate which is tied to a version of pyo3.

On an Apple M1, of extensions built for release, in microseconds for each Order of the README's Performance section:

pure C++ Rust, before Rust, now
Write Arrow 11.5 0.4 16.2 0.3
Read Arrow 9.4 0.8 14.3 0.7

To know:

  • Two faults of arrow-rs are worked around where tables go to and from Python: it does not say that the keys of a map which is a field are in order, and it takes the rows of a struct within a struct twice where the outer is some of the rows of another, as of a table which has been sliced. Both, and importing a capsule, are a little unsafe.
  • A struct may have 120 fields at most, to be held in Arrow.
  • The extension of the tests is now built with arrow-rs, which is longer to build.

Tested by the tests of Arrow which are for every mode, run with the extension: that its tables have the schema of those of the Python reference, with its metadata, and hold the same, that pyarrow finds them valid, and that each reads the other's. And by a program of Rust alone, which cargo now also runs with the feature.

To come: Parquet from Rust alone, which arrow-rs has, and an example built with maturin.

@nickyoung-github
nickyoung-github merged commit 119a303 into master Nov 29, 2026
6 checks passed
@nickyoung-github
nickyoung-github deleted the feature/rust-arrow branch November 29, 2026 22:24
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.

1 participant