Skip to main content

ArrowImportVTable

Trait ArrowImportVTable 

Source
pub trait ArrowImportVTable:
    'static
    + Send
    + Sync
    + Debug {
    // Required methods
    fn arrow_ext_id(&self) -> Id;
    fn from_arrow_field(
        &self,
        field: &Field,
        session: &ArrowSession,
    ) -> VortexResult<Option<DType>>;
    fn from_arrow_array(
        &self,
        array: ArrowArrayRef,
        field: &Field,
        dtype: &DType,
        session: &ArrowSession,
    ) -> VortexResult<ArrowImport>;
}
Expand description

Plugin layer for importing an Arrow extension-typed array into a Vortex array.

A successful import must preserve each logical Arrow value as described by the field, applying the import nullability rules at each level. The returned array must have the dtype inferred from the field, as checked by ArrowSession. See ArrowExportVTable for the Vortex-to-Arrow round-trip contract.

Prefer crate::ArrowExtVTable for automatic Vortex metadata transport.

Plugins are dispatched by arrow_ext_id. The session peels Arrow dictionaries before it dispatches. The session uses the dictionary field’s metadata to import the values because Arrow gives dictionary values a bare DataType. It then wraps the imported values in a vortex_array::arrays::DictArray with the dictionary’s codes. Run-end values carry their own Field and metadata.

A plugin must defer only an input that another plugin under the same Arrow extension name owns, by returning None from from_arrow_field or ArrowImport::Unsupported from from_arrow_array. An input that no plugin takes imports as plain storage and loses its type, so a field or array that names the plugin’s type but falls outside its domain is an error instead. The arrow.parquet.variant importer is the known exception: it still defers a variant array that is not a struct.

Arrow stores dictionary values as a bare DataType, so their extension metadata lives on the outer Field. Peeling the dictionary lets the importer see the value type described by that metadata. DataType::RunEndEncoded has a separate values field that can carry its own extension metadata, so its values use the normal nested-field import path.

This is purely an implementation trait, its methods should not be called directly. Instead, use the methods on ArrowSession.

Required Methods§

Source

fn arrow_ext_id(&self) -> Id

The Arrow extension name this plugin handles.

Source

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

Build the Vortex DType that corresponds to field (which carries this plugin’s Arrow extension metadata), or None to defer it.

session is provided so plugins can resolve nested or storage fields through the plugin-aware conversion (e.g. ArrowSession::from_arrow_datatype) instead of the naive Arrow → Vortex mapping.

Source

fn from_arrow_array( &self, array: ArrowArrayRef, field: &Field, dtype: &DType, session: &ArrowSession, ) -> VortexResult<ArrowImport>

Convert an Arrow array into a Vortex array of dtype.

Returns ownership of array via ArrowImport::Unsupported to defer it.

The importer receives the Arrow nulls as supplied. It must apply the import nullability rules to each level it converts. Use ArrowSession::from_arrow_storage when the Arrow layout matches the storage layout of dtype. When importing storage with another layout, pass a nullability to ArrowSession::from_arrow_array to avoid dispatching this plugin again.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§