Skip to main content

TableRow

Trait TableRow 

Source
pub trait TableRow: Sized {
    const COLUMNS: usize;

    // Required methods
    fn column_types() -> Result<Vec<LogicalType>>;
    fn write_row(
        self,
        cols: &mut [VectorMut<'_>],
        row: usize,
        projection: Option<&[usize]>,
    ) -> UdfResult<()>;
}
Expand description

One output row of a table function: a tuple of values, one per column, in column order.

Implemented only for tuples — never for a bare T — so that a single-column function’s Item = T and a multi-column function’s Item = (A, B, ...) cannot both match the same blanket impl. The #[duckdb_table_function] macro wraps a non-tuple Item type in a one-element tuple during code generation, so callers never need to write (T,) themselves.

Required Associated Constants§

Source

const COLUMNS: usize

The number of columns this row produces.

Required Methods§

Source

fn column_types() -> Result<Vec<LogicalType>>

The DuckDB logical type of each column, in order.

§Errors

Returns an error if a column’s logical type cannot be built.

Source

fn write_row( self, cols: &mut [VectorMut<'_>], row: usize, projection: Option<&[usize]>, ) -> UdfResult<()>

Writes each element into the matching column vector at row.

projection, when Some, lists which logical column each entry of cols corresponds to (DuckDB only allocates vectors for the columns a pushdown-enabled query actually requested, in that order — cols may then be shorter than COLUMNS, and cols[i] is logical column projection[i], not column i). None means every column is wanted, in order (cols.len() == COLUMNS).

§Errors

Returns an error if a value cannot be converted to a DuckDB value, or if projection names a column index outside 0..COLUMNS.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<A: ScalarRet + DuckLogicalType, B: ScalarRet + DuckLogicalType, C: ScalarRet + DuckLogicalType, D: ScalarRet + DuckLogicalType, E: ScalarRet + DuckLogicalType, F: ScalarRet + DuckLogicalType, G: ScalarRet + DuckLogicalType, H: ScalarRet + DuckLogicalType> TableRow for (A, B, C, D, E, F, G, H)

Source§

const COLUMNS: usize = 8

Source§

fn column_types() -> Result<Vec<LogicalType>>

Source§

fn write_row( self, cols: &mut [VectorMut<'_>], row: usize, projection: Option<&[usize]>, ) -> UdfResult<()>

Source§

impl<A: ScalarRet + DuckLogicalType, B: ScalarRet + DuckLogicalType, C: ScalarRet + DuckLogicalType, D: ScalarRet + DuckLogicalType, E: ScalarRet + DuckLogicalType, F: ScalarRet + DuckLogicalType, G: ScalarRet + DuckLogicalType> TableRow for (A, B, C, D, E, F, G)

Source§

const COLUMNS: usize = 7

Source§

fn column_types() -> Result<Vec<LogicalType>>

Source§

fn write_row( self, cols: &mut [VectorMut<'_>], row: usize, projection: Option<&[usize]>, ) -> UdfResult<()>

Source§

impl<A: ScalarRet + DuckLogicalType, B: ScalarRet + DuckLogicalType, C: ScalarRet + DuckLogicalType, D: ScalarRet + DuckLogicalType, E: ScalarRet + DuckLogicalType, F: ScalarRet + DuckLogicalType> TableRow for (A, B, C, D, E, F)

Source§

const COLUMNS: usize = 6

Source§

fn column_types() -> Result<Vec<LogicalType>>

Source§

fn write_row( self, cols: &mut [VectorMut<'_>], row: usize, projection: Option<&[usize]>, ) -> UdfResult<()>

Source§

impl<A: ScalarRet + DuckLogicalType, B: ScalarRet + DuckLogicalType, C: ScalarRet + DuckLogicalType, D: ScalarRet + DuckLogicalType, E: ScalarRet + DuckLogicalType> TableRow for (A, B, C, D, E)

Source§

const COLUMNS: usize = 5

Source§

fn column_types() -> Result<Vec<LogicalType>>

Source§

fn write_row( self, cols: &mut [VectorMut<'_>], row: usize, projection: Option<&[usize]>, ) -> UdfResult<()>

Source§

impl<A: ScalarRet + DuckLogicalType, B: ScalarRet + DuckLogicalType, C: ScalarRet + DuckLogicalType, D: ScalarRet + DuckLogicalType> TableRow for (A, B, C, D)

Source§

const COLUMNS: usize = 4

Source§

fn column_types() -> Result<Vec<LogicalType>>

Source§

fn write_row( self, cols: &mut [VectorMut<'_>], row: usize, projection: Option<&[usize]>, ) -> UdfResult<()>

Source§

impl<A: ScalarRet + DuckLogicalType, B: ScalarRet + DuckLogicalType, C: ScalarRet + DuckLogicalType> TableRow for (A, B, C)

Source§

const COLUMNS: usize = 3

Source§

fn column_types() -> Result<Vec<LogicalType>>

Source§

fn write_row( self, cols: &mut [VectorMut<'_>], row: usize, projection: Option<&[usize]>, ) -> UdfResult<()>

Source§

impl<A: ScalarRet + DuckLogicalType, B: ScalarRet + DuckLogicalType> TableRow for (A, B)

Source§

const COLUMNS: usize = 2

Source§

fn column_types() -> Result<Vec<LogicalType>>

Source§

fn write_row( self, cols: &mut [VectorMut<'_>], row: usize, projection: Option<&[usize]>, ) -> UdfResult<()>

Source§

impl<A: ScalarRet + DuckLogicalType> TableRow for (A,)

Source§

const COLUMNS: usize = 1

Source§

fn column_types() -> Result<Vec<LogicalType>>

Source§

fn write_row( self, cols: &mut [VectorMut<'_>], row: usize, projection: Option<&[usize]>, ) -> UdfResult<()>

Implementors§