Expand description
§marrow - minimalist Arrow interop
marrow allows building and viewing arrow arrays of different implementations using a unified
interface. The motivation behind marrow is to allow libraries to target multiple different
arrow versions simultaneously.
Supported arrow implementations:
The main types are
Array: an array with owned dataView: an array with borrowed dataField: the data type and metadata of a fieldDataType: data types of arrays
§Conversions
marrow offers conversions between its types and the types of different arrow versions. See the
features section how to enable support for a specific version. The following
conversion are implemented.
From marrow to arrow:
TryFrom<marrow::array::Array> for arrow::array::ArrayRefTryFrom<&marrow::datatypes::Field> for arrow::datatypes::FieldTryFrom<&marrow::datatypes::DataType> for arrow::datatypes::DataTypeTryFrom<marrow::datatypes::TimeUnit> for arrow::datatypes::TimeUnitTryFrom<marrow::datatypes::UnionMode> for arrow::datatypes::UnionMode
From arrow to marrow:
TryFrom<&dyn arrow::array::Array> formarrow::view::View<'_>TryFrom<&arrow::datatypes::Field> formarrow::datatypes::FieldTryFrom<&arrow::datatypes::DataType> formarrow::datatypes::DataTypeTryFrom<arrow::datatypes::TimeUnit> formarrow::datatypes::TimeUnitTryFrom<arrow::datatypes::UnionMode> formarrow::datatypes::UnionMode
For arrow2 the corresponding conversions are implemented.
For example to access the data in an arrow array:
use arrow::array::Int32Array;
use marrow::view::View;
// build the arrow array
let arrow_array = Int32Array::from(vec![Some(1), Some(2), Some(3)]);
// construct a view of this array
let marrow_view = View::try_from(&arrow_array as &dyn arrow::array::Array)?;
// access the underlying data
let View::Int32(marrow_view) = marrow_view else { panic!() };
assert_eq!(marrow_view.values, &[1, 2, 3]);Or to build an array:
use arrow::array::Array as _;
use marrow::array::{Array, PrimitiveArray};
// build the array
let marrow_array = Array::Int32(PrimitiveArray {
validity: Some(marrow::bit_vec![true, false, true]),
values: vec![4, 0, 6],
});
// convert it to an arrow array
let arrow_array_ref = arrow::array::ArrayRef::try_from(marrow_array)?;
assert_eq!(arrow_array_ref.is_null(0), false);
assert_eq!(arrow_array_ref.is_null(1), true);
assert_eq!(arrow_array_ref.is_null(2), false);§Features
Supported features:
serde: enable Serde serialization / deserialization for schema types (Field, DataType, …). The format will match thearrowcratearrow-{version}: enable conversions betweenmarrowandarrow={version}arrow2-{version}: enable conversions betweenmarrowandarrow2={version}
This crate supports conversions from and to different version of arrow or arrow2. These
conversions can be enabled by selecting the relevant features. Any combination of features can
be selected, e.g., both arrow-53 and arrow-52 can be used at the same time.
Supported arrow versions:
| Feature | Arrow Version |
|---|---|
arrow-56 | arrow=56 |
arrow-55 | arrow=55 |
arrow-54 | arrow=54 |
arrow-53 | arrow=53 |
arrow-52 | arrow=52 |
arrow-51 | arrow=51 |
arrow-50 | arrow=50 |
arrow-49 | arrow=49 |
arrow-48 | arrow=48 |
arrow-47 | arrow=47 |
arrow-46 | arrow=46 |
arrow-45 | arrow=45 |
arrow-44 | arrow=44 |
arrow-43 | arrow=43 |
arrow-42 | arrow=42 |
arrow-41 | arrow=41 |
arrow-40 | arrow=40 |
arrow-39 | arrow=39 |
arrow-38 | arrow=38 |
arrow-37 | arrow=37 |
arrow2-0-17 | arrow2=0.17 |
arrow2-0-16 | arrow2=0.16 |
Note, arrow2=0.18 is not supported as the source code was not tagged on GitHub.
Modules§
- array
- Arrays with owned data
- bits
- Helpers to work with bit vectors
- datatypes
- Supported data types
- error
- Error handling in
marrow - types
- Specialized element types of arrays
- view
- Arrays with borrowed data