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§
Sourcefn add_table(
&mut self,
table_path: &[&str],
columns: Vec<(String, DataType)>,
) -> Result<(), SchemaError>
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).
Sourcefn column_names(&self, table_path: &[&str]) -> Result<Vec<String>, SchemaError>
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.
Sourcefn get_column_type(
&self,
table_path: &[&str],
column: &str,
) -> Result<DataType, SchemaError>
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.
Sourcefn has_column(&self, table_path: &[&str], column: &str) -> bool
fn has_column(&self, table_path: &[&str], column: &str) -> bool
Check whether a column exists in the given table.
Provided Methods§
Sourcefn get_udf_type(&self, _name: &str) -> Option<&DataType>
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.