Skip to main content

VCast

Trait VCast 

Source
pub trait VCast: Sized {
    type Shared: Send + Sync + 'static;

    // Required methods
    fn source_type() -> Result<LogicalType>;
    fn target_type() -> Result<LogicalType>;
    fn cast_row(
        shared: &Self::Shared,
        input: &VectorRef<'_>,
        output: &mut VectorMut<'_>,
        row: usize,
    ) -> UdfResult<()>;

    // Provided method
    fn implicit_cast_cost() -> i64 { ... }
}
Expand description

A DuckDB custom cast: converts values of a source logical type to a target type.

See the callback-containment contract in crate::udf.

Required Associated Types§

Source

type Shared: Send + Sync + 'static

Registration-time shared state, available read-only to the cast callback. Use () if the cast needs none.

Required Methods§

Source

fn source_type() -> Result<LogicalType>

The source (input) logical type.

§Errors

Returns an error if the type cannot be built.

Source

fn target_type() -> Result<LogicalType>

The target (output) logical type.

§Errors

Returns an error if the type cannot be built.

Source

fn cast_row( shared: &Self::Shared, input: &VectorRef<'_>, output: &mut VectorMut<'_>, row: usize, ) -> UdfResult<()>

Converts input[row] and writes it to output[row].

§Errors

Returns an error for a value that cannot be converted. Under a normal CAST the query fails with that message; under TRY_CAST the output row is set to NULL instead.

Provided Methods§

Source

fn implicit_cast_cost() -> i64

The implicit-cast cost the binder uses to choose this cast (lower = preferred; a negative value disables implicit application, requiring an explicit CAST). Defaults to -1 (explicit only).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§