pub struct SqlToRel<'a, S: ContextProvider> { /* private fields */ }
Expand description
SQL query planner and binder
This struct is used to convert a SQL AST into a LogicalPlan
.
You can control the behavior of the planner by providing ParserOptions
.
It performs the following tasks:
- Name and type resolution (called “binding” in other systems). This
phase looks up table and column names using the
ContextProvider
. - Mechanical translation of the AST into a
LogicalPlan
.
It does not perform type coercion, or perform optimization, which are done by subsequent passes.
Key interfaces are:
Self::sql_statement_to_plan
: Convert a statement (e.g.SELECT ...
) into aLogicalPlan
Self::sql_to_expr
: Convert an expression (e.g.1 + 2
) into anExpr
Implementations§
Source§impl<S: ContextProvider> SqlToRel<'_, S>
impl<S: ContextProvider> SqlToRel<'_, S>
pub fn sql_to_expr_with_alias( &self, sql: SQLExprWithAlias, schema: &DFSchema, planner_context: &mut PlannerContext, ) -> Result<Expr>
Sourcepub fn sql_to_expr(
&self,
sql: SQLExpr,
schema: &DFSchema,
planner_context: &mut PlannerContext,
) -> Result<Expr>
pub fn sql_to_expr( &self, sql: SQLExpr, schema: &DFSchema, planner_context: &mut PlannerContext, ) -> Result<Expr>
Generate a relational expression from a SQL expression
Source§impl<'a, S: ContextProvider> SqlToRel<'a, S>
impl<'a, S: ContextProvider> SqlToRel<'a, S>
Sourcepub fn new(context_provider: &'a S) -> Self
pub fn new(context_provider: &'a S) -> Self
Create a new query planner.
The query planner derives the parser options from the context provider.
Sourcepub fn new_with_options(context_provider: &'a S, options: ParserOptions) -> Self
pub fn new_with_options(context_provider: &'a S, options: ParserOptions) -> Self
Create a new query planner with the given parser options.
The query planner ignores the parser options from the context provider and uses the given parser options instead.
pub fn build_schema(&self, columns: Vec<SQLColumnDef>) -> Result<Schema>
Source§impl<S: ContextProvider> SqlToRel<'_, S>
impl<S: ContextProvider> SqlToRel<'_, S>
Sourcepub fn statement_to_plan(&self, statement: DFStatement) -> Result<LogicalPlan>
pub fn statement_to_plan(&self, statement: DFStatement) -> Result<LogicalPlan>
Generate a logical plan from an DataFusion SQL statement
Sourcepub fn sql_statement_to_plan(&self, statement: Statement) -> Result<LogicalPlan>
pub fn sql_statement_to_plan(&self, statement: Statement) -> Result<LogicalPlan>
Generate a logical plan from an SQL statement
Sourcepub fn sql_statement_to_plan_with_context(
&self,
statement: Statement,
planner_context: &mut PlannerContext,
) -> Result<LogicalPlan>
pub fn sql_statement_to_plan_with_context( &self, statement: Statement, planner_context: &mut PlannerContext, ) -> Result<LogicalPlan>
Generate a logical plan from an SQL statement
Sourcepub fn new_constraint_from_table_constraints(
&self,
constraints: &[TableConstraint],
df_schema: &DFSchemaRef,
) -> Result<Constraints>
pub fn new_constraint_from_table_constraints( &self, constraints: &[TableConstraint], df_schema: &DFSchemaRef, ) -> Result<Constraints>
Convert each TableConstraint to corresponding Constraint
Auto Trait Implementations§
impl<'a, S> Freeze for SqlToRel<'a, S>
impl<'a, S> RefUnwindSafe for SqlToRel<'a, S>where
S: RefUnwindSafe,
impl<'a, S> Send for SqlToRel<'a, S>where
S: Sync,
impl<'a, S> Sync for SqlToRel<'a, S>where
S: Sync,
impl<'a, S> Unpin for SqlToRel<'a, S>
impl<'a, S> UnwindSafe for SqlToRel<'a, S>where
S: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more