Skip to main content

vortex_array/arrow/
mod.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4//! Utilities to work with `Arrow` data and types.
5
6use arrow_array::ArrayRef as ArrowArrayRef;
7use arrow_schema::DataType;
8use vortex_error::VortexResult;
9
10mod convert;
11mod datum;
12mod executor;
13mod iter;
14mod null_buffer;
15mod record_batch;
16
17pub use datum::*;
18pub use executor::*;
19pub use iter::*;
20pub use null_buffer::to_arrow_null_buffer;
21pub use null_buffer::to_null_buffer;
22
23use crate::ArrayRef;
24use crate::LEGACY_SESSION;
25use crate::VortexSessionExecute;
26
27pub trait FromArrowArray<A> {
28    fn from_arrow(array: A, nullable: bool) -> VortexResult<Self>
29    where
30        Self: Sized;
31}
32
33#[deprecated(note = "Use `execute_arrow(None, ctx)` or `execute_arrow(Some(dt), ctx)` instead")]
34pub trait IntoArrowArray {
35    #[deprecated(note = "Use `execute_arrow(None, ctx)` instead")]
36    fn into_arrow_preferred(self) -> VortexResult<ArrowArrayRef>;
37
38    #[deprecated(note = "Use `execute_arrow(Some(data_type), ctx)` instead")]
39    fn into_arrow(self, data_type: &DataType) -> VortexResult<ArrowArrayRef>;
40}
41
42#[allow(deprecated)]
43impl IntoArrowArray for ArrayRef {
44    /// Convert this [`crate::ArrayRef`] into an Arrow [`crate::ArrayRef`] by using the array's
45    /// preferred (cheapest) Arrow [`DataType`].
46    fn into_arrow_preferred(self) -> VortexResult<ArrowArrayRef> {
47        self.execute_arrow(None, &mut LEGACY_SESSION.create_execution_ctx())
48    }
49
50    fn into_arrow(self, data_type: &DataType) -> VortexResult<ArrowArrayRef> {
51        self.execute_arrow(Some(data_type), &mut LEGACY_SESSION.create_execution_ctx())
52    }
53}