Skip to main content

ContextProvider

Trait ContextProvider 

Source
pub trait ContextProvider {
Show 18 methods // Required methods fn get_table_source( &self, name: TableReference, ) -> Result<Arc<dyn TableSource>>; fn get_function_meta(&self, name: &str) -> Option<Arc<ScalarUDF>>; fn get_higher_order_meta(&self, name: &str) -> Option<Arc<HigherOrderUDF>>; fn get_aggregate_meta(&self, name: &str) -> Option<Arc<AggregateUDF>>; fn get_window_meta(&self, name: &str) -> Option<Arc<WindowUDF>>; fn get_variable_type(&self, variable_names: &[String]) -> Option<DataType>; fn options(&self) -> &ConfigOptions; fn udf_names(&self) -> Vec<String>; fn higher_order_function_names(&self) -> Vec<String>; fn udaf_names(&self) -> Vec<String>; fn udwf_names(&self) -> Vec<String>; // Provided methods fn get_file_type(&self, _ext: &str) -> Result<Arc<dyn FileType>> { ... } fn get_table_function_source( &self, _name: &str, _args: Vec<Expr>, ) -> Result<Arc<dyn TableSource>> { ... } fn create_cte_work_table( &self, _name: &str, _schema: SchemaRef, ) -> Result<Arc<dyn TableSource>> { ... } fn get_expr_planners(&self) -> &[Arc<dyn ExprPlanner>] { ... } fn get_relation_planners(&self) -> &[Arc<dyn RelationPlanner>] { ... } fn get_type_planner(&self) -> Option<Arc<dyn TypePlanner>> { ... } fn get_variable_field(&self, variable_names: &[String]) -> Option<FieldRef> { ... }
}
Expand description

Provides the SQL query planner meta-data about tables and functions referenced in SQL statements, without a direct dependency on the datafusion Catalog structures such as TableProvider

Required Methods§

Source

fn get_table_source(&self, name: TableReference) -> Result<Arc<dyn TableSource>>

Returns a table by reference, if it exists

Source

fn get_function_meta(&self, name: &str) -> Option<Arc<ScalarUDF>>

Return the scalar function with a given name, if any

Source

fn get_higher_order_meta(&self, name: &str) -> Option<Arc<HigherOrderUDF>>

Return the higher order function with a given name, if any

Source

fn get_aggregate_meta(&self, name: &str) -> Option<Arc<AggregateUDF>>

Return the aggregate function with a given name, if any

Source

fn get_window_meta(&self, name: &str) -> Option<Arc<WindowUDF>>

Return the window function with a given name, if any

Source

fn get_variable_type(&self, variable_names: &[String]) -> Option<DataType>

Return the system/user-defined variable type, if any

A user defined variable is typically accessed via @var_name

Source

fn options(&self) -> &ConfigOptions

Return overall configuration options

Source

fn udf_names(&self) -> Vec<String>

Return all scalar function names

Source

fn higher_order_function_names(&self) -> Vec<String>

Return all higher order function names

Source

fn udaf_names(&self) -> Vec<String>

Return all aggregate function names

Source

fn udwf_names(&self) -> Vec<String>

Return all window function names

Provided Methods§

Source

fn get_file_type(&self, _ext: &str) -> Result<Arc<dyn FileType>>

Return the type of a file based on its extension (e.g. .parquet)

This is used to plan COPY statements

Source

fn get_table_function_source( &self, _name: &str, _args: Vec<Expr>, ) -> Result<Arc<dyn TableSource>>

Getter for a table function

Source

fn create_cte_work_table( &self, _name: &str, _schema: SchemaRef, ) -> Result<Arc<dyn TableSource>>

Provides an intermediate table that is used to store the results of a CTE during execution

CTE stands for “Common Table Expression”

§Notes

We don’t directly implement this in SqlToRel as implementing this function often requires access to a table that contains execution-related types that can’t be a direct dependency of the sql crate (for example CteWorkTable).

The ContextProvider provides a way to “hide” this dependency.

Source

fn get_expr_planners(&self) -> &[Arc<dyn ExprPlanner>]

Return ExprPlanner extensions for planning expressions

Source

fn get_relation_planners(&self) -> &[Arc<dyn RelationPlanner>]

Available on crate feature sql only.

Return RelationPlanner extensions for planning table factors

Source

fn get_type_planner(&self) -> Option<Arc<dyn TypePlanner>>

Available on crate feature sql only.

Return TypePlanner extensions for planning data types

Source

fn get_variable_field(&self, variable_names: &[String]) -> Option<FieldRef>

Return metadata about a system/user-defined variable, if any.

By default, this wraps Self::get_variable_type in an Arrow Field with nullable set to true and no metadata. Implementations that can provide richer information (such as nullability or extension metadata) should override this method.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§