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 session;
16
17pub(crate) use convert::nulls;
18pub use datum::*;
19pub use executor::*;
20pub use iter::*;
21pub use null_buffer::to_arrow_null_buffer;
22pub use null_buffer::to_null_buffer;
23pub use session::*;
24
25use crate::ArrayRef;
26use crate::LEGACY_SESSION;
27use crate::VortexSessionExecute;
28
29pub trait FromArrowArray<A> {
30    fn from_arrow(array: A, nullable: bool) -> VortexResult<Self>
31    where
32        Self: Sized;
33}
34
35#[deprecated(note = "Use `execute_arrow(None, ctx)` or `execute_arrow(Some(dt), ctx)` instead")]
36pub trait IntoArrowArray {
37    #[deprecated(note = "Use `execute_arrow(None, ctx)` instead")]
38    fn into_arrow_preferred(self) -> VortexResult<ArrowArrayRef>;
39
40    #[deprecated(note = "Use `execute_arrow(Some(data_type), ctx)` instead")]
41    fn into_arrow(self, data_type: &DataType) -> VortexResult<ArrowArrayRef>;
42}
43
44#[allow(deprecated)]
45impl IntoArrowArray for ArrayRef {
46    /// Convert this [`crate::ArrayRef`] into an Arrow [`crate::ArrayRef`] by using the array's
47    /// preferred (cheapest) Arrow [`DataType`].
48    fn into_arrow_preferred(self) -> VortexResult<ArrowArrayRef> {
49        self.execute_arrow(None, &mut LEGACY_SESSION.create_execution_ctx())
50    }
51
52    fn into_arrow(self, data_type: &DataType) -> VortexResult<ArrowArrayRef> {
53        self.execute_arrow(Some(data_type), &mut LEGACY_SESSION.create_execution_ctx())
54    }
55}