Skip to main content

ArrowExportVTable

Trait ArrowExportVTable 

Source
pub trait ArrowExportVTable:
    'static
    + Send
    + Sync
    + Debug {
    // Required methods
    fn arrow_ext_id(&self) -> Id;
    fn vortex_id(&self) -> Id;
    fn to_arrow_field(
        &self,
        name: &str,
        dtype: &DType,
        session: &ArrowSession,
    ) -> VortexResult<Option<Field>>;
    fn execute_arrow(
        &self,
        array: ArrayRef,
        target: &Field,
        options: &ArrowExportOptions,
        ctx: &mut ExecutionCtx,
    ) -> VortexResult<ArrowExport>;
}
Expand description

Plugin layer for exporting a Vortex array to an Arrow extension type.

A successful export must preserve the logical value of each row, including nulls. The physical layout can change. For example, a UUID stored as a fixed-size list of 16 bytes can export as Arrow FixedSizeBinary(16) with the same bytes.

Importing an inferred field with ArrowSession::from_arrow_field must recover the complete Vortex dtype passed to ArrowSession::to_arrow_field, including extension IDs, metadata, storage, and nullability at every nesting level. Exporting and importing an array with that field must recover the original dtype and values. Several Arrow representations can import as the same Vortex dtype.

Prefer crate::ArrowExtVTable for automatic Vortex metadata transport.

This is purely an implementation trait, its methods should not be called directly. Instead, use ExecuteArrowExt to export an array, and the methods on ArrowSession to convert a dtype.

Required Methods§

Source

fn arrow_ext_id(&self) -> Id

The Arrow extension ID this plugin produces.

Source

fn vortex_id(&self) -> Id

The Vortex array or extension ID this plugin maps from. Used only for inference by ArrowSession::to_arrow_field / ArrowSession::to_arrow_schema; never as a dispatch key for execute_arrow.

Source

fn to_arrow_field( &self, name: &str, dtype: &DType, session: &ArrowSession, ) -> VortexResult<Option<Field>>

Build the Arrow Field this plugin produces for the given Vortex extension dtype. Used during schema inference.

Source

fn execute_arrow( &self, array: ArrayRef, target: &Field, options: &ArrowExportOptions, ctx: &mut ExecutionCtx, ) -> VortexResult<ArrowExport>

Convert a Vortex array into an Arrow array shaped to target.

Returns ownership of array via ArrowExport::Unsupported when the plugin cannot handle the input. Plugins that export child or storage arrays must pass options on to those exports, through ExecuteArrowExt::execute_arrow_with_options. The ArrowSession of ctx is the session of the export, so a plugin that needs one must use it.

§Exported values

Every export must preserve the nulls of array.

If array has an extension dtype and the output type supports the Arrow comparison kernels, the export must preserve equality and order. Two non-null exported values compare the same way in Arrow as their storage values compare in Vortex. Nested Arrow types only have the null requirement.

The comparison rule holds across batches in one Arrow representation. To push a comparison down to Vortex storage, an engine also needs to know that both operands use compatible representations. Two exporters can each preserve order and still encode equal storage values differently. A round trip alone does not even ensure that one exporter preserves order. An exporter can reverse the bytes of each value and undo that change on import.

A plugin that breaks these rules gives incorrect query results instead of an error. It does not cause memory unsafety. test_harness::check_arrow checks both rules for one array.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§