Skip to main content

Schema

Trait Schema 

Source
pub trait Schema {
    // Required methods
    fn add_table(
        &mut self,
        table_path: &[&str],
        columns: Vec<(String, DataType)>,
    ) -> Result<(), SchemaError>;
    fn column_names(
        &self,
        table_path: &[&str],
    ) -> Result<Vec<String>, SchemaError>;
    fn get_column_type(
        &self,
        table_path: &[&str],
        column: &str,
    ) -> Result<DataType, SchemaError>;
    fn has_column(&self, table_path: &[&str], column: &str) -> bool;
    fn dialect(&self) -> Dialect;

    // Provided method
    fn get_udf_type(&self, _name: &str) -> Option<&DataType> { ... }
}
Expand description

Schema trait for schema-aware analysis and optimization.

Provides methods to query table and column metadata. Implementations can back this with in-memory mappings, database catalogs, etc.

Required Methods§

Source

fn add_table( &mut self, table_path: &[&str], columns: Vec<(String, DataType)>, ) -> Result<(), SchemaError>

Register a table with its column definitions.

table_path is a slice of identifiers representing the fully qualified table path: [catalog, database, table], [database, table], or [table].

§Errors

Returns SchemaError::DuplicateTable if the table is already registered (use replace_table to overwrite).

Source

fn column_names(&self, table_path: &[&str]) -> Result<Vec<String>, SchemaError>

Get the column names for a table, in definition order.

§Errors

Returns SchemaError::TableNotFound if the table is not registered.

Source

fn get_column_type( &self, table_path: &[&str], column: &str, ) -> Result<DataType, SchemaError>

Get the data type of a specific column in a table.

§Errors

Returns SchemaError::TableNotFound or SchemaError::ColumnNotFound.

Source

fn has_column(&self, table_path: &[&str], column: &str) -> bool

Check whether a column exists in the given table.

Source

fn dialect(&self) -> Dialect

Get the dialect used for identifier normalization.

Provided Methods§

Source

fn get_udf_type(&self, _name: &str) -> Option<&DataType>

Get the return type of a registered UDF (user-defined function).

Returns None by default. Implementations that support UDFs should override this method.

Implementors§