Skip to main content

ArrowExtVTable

Trait ArrowExtVTable 

Source
pub trait ArrowExtVTable: ExtVTable {
    // Required methods
    fn metadata_policy() -> ArrowMetadataPolicy;
    fn arrow_ext_id(&self) -> Id;
    fn to_arrow_field(
        &self,
        name: &str,
        ext_dtype: &ExtDType<Self>,
        session: &ArrowSession,
    ) -> VortexResult<Option<Field>>;
    fn execute_arrow(
        &self,
        array: ArrayRef,
        target: &Field,
        options: &ArrowExportOptions,
        ctx: &mut ExecutionCtx,
    ) -> VortexResult<ArrowExport>;
    fn from_arrow_field(
        field: &Field,
        session: &ArrowSession,
    ) -> VortexResult<Option<ExtDType<Self>>>;
    fn from_arrow_array(
        array: ArrowArrayRef,
        field: &Field,
        ext_dtype: &ExtDType<Self>,
        session: &ArrowSession,
    ) -> VortexResult<ArrowImport>;
}
Expand description

Native Arrow conversion callbacks for one Vortex extension type.

The array callbacks must follow the value contracts of crate::ArrowExportVTable and crate::ArrowImportVTable. The adapter carries Vortex metadata so that importing with the inferred Arrow field can recover the original dtype.

Register through ArrowSession::register_extension, and use the session’s conversion APIs. Calling these callbacks directly bypasses metadata transport and schema validation. Callbacks must describe only the native Arrow representation, leaving Vortex metadata transport to the adapter. Register the owning dtype in the Vortex session as well to enable its Vortex ID path.

Register the dtype and its Arrow conversions in the same session:

use vortex_array::dtype::session::DTypeSessionExt;
use vortex_arrow::{ArrowExtVTable, ArrowSessionExt};
use vortex_session::VortexSession;

fn register<V: ArrowExtVTable>(session: &VortexSession, vtable: V) {
    session.dtypes().register(vtable.clone());
    session.arrow().register_extension(vtable);
}

Required Methods§

Source

fn metadata_policy() -> ArrowMetadataPolicy

The metadata policy used by the adapter for this extension type.

The result must remain the same across calls and sessions.

Source

fn arrow_ext_id(&self) -> Id

The native Arrow extension ID used for both import and export.

Source

fn to_arrow_field( &self, name: &str, ext_dtype: &ExtDType<Self>, session: &ArrowSession, ) -> VortexResult<Option<Field>>

Builds the native field, or declines so that the session uses the Vortex ID path.

Use Field::try_with_extension_type for standard Arrow extension metadata, or crate::ext_metadata::set_arrow_extension_name for a custom name. The adapter adds any Vortex metadata before the session validates the completed field against the source dtype.

Source

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

Converts an array of this extension type to the native target representation.

The adapter checks the source extension type before calling this method. Return ArrowExport::Unsupported when the target is unsupported. Child exports must receive the same options through crate::ExecuteArrowExt::execute_arrow_with_options.

The export must follow the null and comparison rules.

Source

fn from_arrow_field( field: &Field, session: &ArrowSession, ) -> VortexResult<Option<ExtDType<Self>>>

Interprets the native field, without applying Vortex side metadata.

Infer the Vortex storage representation here, which can differ from Arrow’s physical type. Return None only to defer the field to another plugin under the same Arrow extension name. A field that names this type but falls outside its domain must fail, as ArrowImportVTable states.

Source

fn from_arrow_array( array: ArrowArrayRef, field: &Field, ext_dtype: &ExtDType<Self>, session: &ArrowSession, ) -> VortexResult<ArrowImport>

Imports native values with the extension dtype restored by the adapter.

ext_dtype includes any Vortex metadata restored by the adapter, so this callback does not need to decode it. Inferring the dtype again from the native Arrow representation could lose that metadata.

A successful result must have exactly ext_dtype and the input length. Return ArrowImport::Unsupported only to defer the array to another plugin under the same Arrow extension name, as ArrowImportVTable states.

See the importer contract for how to apply the storage dtype’s nullability.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§