Skip to main content

LogicalTypeProvider

Trait LogicalTypeProvider 

Source
pub trait LogicalTypeProvider: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn arrow_type(&self) -> DataType;
    fn from_literal(&self, s: &str) -> Result<ScalarValue, FnError>;
    fn to_display(&self, v: &ScalarValue) -> Result<String, FnError>;
    fn cast_to(
        &self,
        v: &ColumnarValue,
        target: &DataType,
    ) -> Result<ColumnarValue, FnError>;
    fn cast_from(&self, v: &ColumnarValue) -> Result<ColumnarValue, FnError>;

    // Provided methods
    fn encoding_version(&self) -> &str { ... }
    fn compat_check(&self, old: &dyn LogicalTypeProvider) -> Result<(), FnError> { ... }
}
Expand description

A logical type plugin (Arrow extension type).

Required Methods§

Source

fn name(&self) -> &str

Extension name stored in ARROW:extension:name.

Source

fn arrow_type(&self) -> DataType

Physical Arrow storage type backing this logical type.

Source

fn from_literal(&self, s: &str) -> Result<ScalarValue, FnError>

Parse a Cypher / Locy literal into the logical-typed scalar.

§Errors

Returns FnError if the literal is malformed for this type.

Source

fn to_display(&self, v: &ScalarValue) -> Result<String, FnError>

Render a logical-typed value for display.

§Errors

Returns FnError if the value cannot be rendered.

Source

fn cast_to( &self, v: &ColumnarValue, target: &DataType, ) -> Result<ColumnarValue, FnError>

Convert this logical-typed column to a different target type.

§Errors

Returns FnError if the cast is unsupported.

Source

fn cast_from(&self, v: &ColumnarValue) -> Result<ColumnarValue, FnError>

Convert from a physical column to this logical type.

§Errors

Returns FnError if the source representation is incompatible.

Provided Methods§

Source

fn encoding_version(&self) -> &str

Optional opaque version stamp for the on-disk encoding.

Default is "1". Override when bumping an encoding-breaking change so Self::compat_check can reject a reload that would silently mis-decode already-persisted data.

Source

fn compat_check(&self, old: &dyn LogicalTypeProvider) -> Result<(), FnError>

Reject a reload that would change the Arrow extension contract.

Default implementation enforces the §11.2.1 invariant: the new provider must keep the same extension name() and the same physical arrow_type() and the same Self::encoding_version as the old provider. Any mismatch is a hard reload error because previously-stored values would otherwise become unreadable.

§Errors

Returns FnError (code FnError::CODE_TYPE_COERCION) when the new provider’s contract differs from the old.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§