Skip to main content

vortex_datafusion/convert/
mod.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4//! Utilities and interface to convert DataFusion types to Vortex types.
5//!
6//! Currently includes:
7//! [`ExpressionConvertor`] - Controls the rewrite of DataFusion expressions to Vortex expressions, and whether they can
8//! be pushed into the underlying scan. A default implementation is provided.
9//! [`FromDataFusion`] - Converts a DataFusion type into a Vortex type infallible.
10//! [TryToDataFusion] - Fallibly converts a Vortex type to a DataFusion type.
11
12use vortex::error::VortexResult;
13
14pub(crate) mod exprs;
15mod scalars;
16pub(crate) mod schema;
17pub(crate) mod stats;
18
19pub use exprs::DefaultExpressionConvertor;
20pub use exprs::ExpressionConvertor;
21
22/// First-party trait for implementing conversion from DataFusion types to Vortex types.
23pub trait FromDataFusion<D: ?Sized>: Sized {
24    /// Convert to this Vortex type from the input DataFusion type.
25    fn from_df(df: &D) -> Self;
26}
27
28/// First-party trait for implementing fallible conversions from Vortex to DataFusion types.
29pub trait TryToDataFusion<D> {
30    /// Try to convert this Vortex type from the input DataFusion type.
31    fn try_to_df(&self) -> VortexResult<D>;
32}