Trait TableSource

Source
pub trait TableSource: Sync + Send {
    // Required methods
    fn as_any(&self) -> &(dyn Any + 'static);
    fn schema(&self) -> Arc<Schema>;

    // Provided methods
    fn constraints(&self) -> Option<&Constraints> { ... }
    fn table_type(&self) -> TableType { ... }
    fn supports_filters_pushdown(
        &self,
        filters: &[&Expr],
    ) -> Result<Vec<TableProviderFilterPushDown>, DataFusionError> { ... }
    fn get_logical_plan(&self) -> Option<Cow<'_, LogicalPlan>> { ... }
    fn get_column_default(&self, _column: &str) -> Option<&Expr> { ... }
}
Expand description

Planning time information about a table.

This trait is used during logical query planning and optimizations, and provides a subset of the TableProvider trait, such as schema information and filter push-down capabilities. The TableProvider trait provides additional information needed for physical query execution, such as the ability to perform a scan or insert data.

§See Also:

DefaultTableSource to go from TableProvider, to TableSource

§Rationale

The reason for having two separate traits is to avoid having the logical plan code be dependent on the DataFusion execution engine. Some projects use DataFusion’s logical plans and have their own execution engine.

Required Methods§

Source

fn as_any(&self) -> &(dyn Any + 'static)

Source

fn schema(&self) -> Arc<Schema>

Get a reference to the schema for this table

Provided Methods§

Source

fn constraints(&self) -> Option<&Constraints>

Get primary key indices, if any

Source

fn table_type(&self) -> TableType

Get the type of this table for metadata/catalog purposes.

Source

fn supports_filters_pushdown( &self, filters: &[&Expr], ) -> Result<Vec<TableProviderFilterPushDown>, DataFusionError>

Tests whether the table provider can make use of any or all filter expressions to optimize data retrieval. Only non-volatile expressions are passed to this function.

Source

fn get_logical_plan(&self) -> Option<Cow<'_, LogicalPlan>>

Get the Logical plan of this table provider, if available.

For example, a view may have a logical plan, but a CSV file does not.

Source

fn get_column_default(&self, _column: &str) -> Option<&Expr>

Get the default value for a column, if available.

Implementations on Foreign Types§

Source§

impl TableSource for DefaultTableSource

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Returns the table source as Any so that it can be downcast to a specific implementation.

Source§

fn schema(&self) -> Arc<Schema>

Get a reference to the schema for this table

Source§

fn constraints(&self) -> Option<&Constraints>

Get a reference to applicable constraints, if any exists.

Source§

fn table_type(&self) -> TableType

Get the type of this table for metadata/catalog purposes.

Source§

fn supports_filters_pushdown( &self, filter: &[&Expr], ) -> Result<Vec<TableProviderFilterPushDown>, DataFusionError>

Tests whether the table provider can make use of any or all filter expressions to optimize data retrieval.

Source§

fn get_logical_plan(&self) -> Option<Cow<'_, LogicalPlan>>

Source§

fn get_column_default(&self, column: &str) -> Option<&Expr>

Implementors§

Source§

impl TableSource for SqlTableSource

Implement TableSource, used in the logical query plan and in logical query optimizations

Source§

impl TableSource for LogicalTableSource