pub struct Binder {Show 19 fields
catalog: ArcRwLockReadGuard<RawRwLock, Catalog>,
db_name: String,
session_id: SessionId,
context: BindContext,
auth_context: Arc<AuthContext>,
upper_subquery_contexts: Vec<(BindContext, Vec<LateralBindContext>)>,
lateral_contexts: Vec<LateralBindContext>,
next_subquery_id: usize,
next_values_id: usize,
next_share_id: usize,
session_config: Arc<RwLock<SessionConfig>>,
search_path: SearchPath,
bind_for: BindFor,
shared_views: HashMap<u32, usize>,
included_relations: HashSet<TableId>,
included_udfs: HashSet<FunctionId>,
param_types: ParameterTypes,
udf_context: UdfContext,
temporary_source_manager: TemporarySourceManager,
}
Expand description
Binder
binds the identifiers in AST to columns in relations
Fields§
§catalog: ArcRwLockReadGuard<RawRwLock, Catalog>
§db_name: String
§session_id: SessionId
§context: BindContext
§auth_context: Arc<AuthContext>
§upper_subquery_contexts: Vec<(BindContext, Vec<LateralBindContext>)>
A stack holding contexts of outer queries when binding a subquery. It also holds all of the lateral contexts for each respective subquery.
See Binder::bind_subquery_expr
for details.
lateral_contexts: Vec<LateralBindContext>
A stack holding contexts of left-lateral TableFactor
s.
We need a separate stack as CorrelatedInputRef
depth is
determined by the upper subquery context depth, not the lateral context stack depth.
next_subquery_id: usize
§next_values_id: usize
The ShareId
is used to identify the share relation which could be a CTE, a source, a view
and so on.
session_config: Arc<RwLock<SessionConfig>>
§search_path: SearchPath
§bind_for: BindFor
The type of binding statement.
ShareId
s identifying shared views.
included_relations: HashSet<TableId>
The included relations while binding a query.
included_udfs: HashSet<FunctionId>
The included user-defined functions while binding a query.
param_types: ParameterTypes
§udf_context: UdfContext
The sql udf context that will be used during binding phase
temporary_source_manager: TemporarySourceManager
The temporary sources that will be used during binding phase
Implementations§
source§impl Binder
impl Binder
pub fn bind_columns_to_context( &mut self, name: String, column_catalogs: &[ColumnCatalog], ) -> Result<(), RwError>
pub fn get_column_binding_index( &mut self, table_name: String, column_name: &String, ) -> Result<usize, RwError>
source§impl Binder
impl Binder
pub(super) fn bind_delete( &mut self, name: ObjectName, selection: Option<Expr>, returning_items: Vec<SelectItem>, ) -> Result<BoundDelete, RwError>
source§impl Binder
impl Binder
pub(super) fn bind_binary_op( &mut self, left: Expr, op: BinaryOperator, right: Expr, ) -> Result<ExprImpl, RwError>
fn resolve_binary_operator( op: BinaryOperator, bound_left: &ExprImpl, bound_right: &ExprImpl, ) -> Result<Vec<ExprType>, RwError>
source§impl Binder
impl Binder
fn ensure_aggregate_allowed(&self) -> Result<(), RwError>
pub(super) fn bind_aggregate_function( &mut self, agg_type: AggType, distinct: bool, args: Vec<ExprImpl>, order_by: Vec<OrderByExpr>, within_group: Option<Box<OrderByExpr>>, filter: Option<Box<Expr>>, ) -> Result<ExprImpl, RwError>
fn bind_ordered_set_agg( &mut self, kind: &AggType, distinct: bool, args: Vec<ExprImpl>, order_by: Vec<OrderByExpr>, within_group: Option<Box<OrderByExpr>>, ) -> Result<(Vec<Literal>, Vec<ExprImpl>, OrderBy), RwError>
fn bind_normal_agg( &mut self, kind: &AggType, distinct: bool, args: Vec<ExprImpl>, order_by: Vec<OrderByExpr>, within_group: Option<Box<OrderByExpr>>, ) -> Result<(Vec<Literal>, Vec<ExprImpl>, OrderBy), RwError>
source§impl Binder
impl Binder
fn ensure_window_function_allowed(&self) -> Result<(), RwError>
sourcepub(super) fn bind_window_function(
&mut self,
kind: WindowFuncKind,
args: Vec<ExprImpl>,
ignore_nulls: bool,
filter: Option<Box<Expr>>,
_: WindowSpec,
) -> Result<ExprImpl, RwError>
pub(super) fn bind_window_function( &mut self, kind: WindowFuncKind, args: Vec<ExprImpl>, ignore_nulls: bool, filter: Option<Box<Expr>>, _: WindowSpec, ) -> Result<ExprImpl, RwError>
Bind window function calls according to PostgreSQL syntax. See https://www.postgresql.org/docs/current/sql-expressions.html#SYNTAX-WINDOW-FUNCTIONS for syntax detail.
fn bind_window_frame_usize_bounds( &mut self, start: WindowFrameBound, end: Option<WindowFrameBound>, ) -> Result<(FrameBound<usize>, FrameBound<usize>), RwError>
fn bind_window_frame_scalar_impl_bounds( &mut self, start: WindowFrameBound, end: Option<WindowFrameBound>, offset_data_type: &DataType, ) -> Result<(FrameBound<ScalarImpl>, FrameBound<ScalarImpl>), RwError>
fn bind_window_frame_bound_offset( &mut self, offset: Expr, cast_to: DataType, ) -> Result<ScalarImpl, RwError>
source§impl Binder
impl Binder
pub(in binder) fn bind_function( &mut self, _: Function, ) -> Result<ExprImpl, RwError>
fn bind_array_transform( &mut self, args: Vec<FunctionArg>, ) -> Result<ExprImpl, RwError>
fn bind_unary_lambda_function( &mut self, input_ty: DataType, arg: Ident, body: Expr, ) -> Result<ExprImpl, RwError>
fn ensure_table_function_allowed(&self) -> Result<(), RwError>
fn bind_sql_udf( &mut self, func: Arc<FunctionCatalog>, args: Vec<ExprImpl>, ) -> Result<ExprImpl, RwError>
pub(in binder) fn bind_function_expr_arg( &mut self, arg_expr: FunctionArgExpr, ) -> Result<Vec<ExprImpl>, RwError>
pub(in binder) fn bind_function_arg( &mut self, arg: FunctionArg, ) -> Result<Vec<ExprImpl>, RwError>
source§impl Binder
impl Binder
sourcepub(super) fn bind_order_by_expr(
&mut self,
_: OrderByExpr,
) -> Result<BoundOrderByExpr, RwError>
pub(super) fn bind_order_by_expr( &mut self, _: OrderByExpr, ) -> Result<BoundOrderByExpr, RwError>
Bind an ORDER BY
expression in other places than
Query
,
including in OVER
and in aggregate functions.
Different from a query-level ORDER BY
(Self::bind_order_by_expr_in_query
),
output-column names or numbers are not allowed here.
source§impl Binder
impl Binder
pub fn bind_subquery_expr( &mut self, query: Query, kind: SubqueryKind, ) -> Result<ExprImpl, RwError>
source§impl Binder
impl Binder
pub fn bind_value(&mut self, value: Value) -> Result<Literal, RwError>
pub(super) fn bind_string(&mut self, s: String) -> Result<Literal, RwError>
fn bind_bool(&mut self, b: bool) -> Result<Literal, RwError>
fn bind_number(&mut self, s: String) -> Result<Literal, RwError>
fn bind_interval( &mut self, s: String, leading_field: Option<AstDateTimeField>, ) -> Result<Literal, RwError>
pub(crate) fn bind_date_time_field(field: AstDateTimeField) -> DateTimeField
sourcepub(super) fn bind_array(
&mut self,
exprs: Vec<Expr>,
) -> Result<ExprImpl, RwError>
pub(super) fn bind_array( &mut self, exprs: Vec<Expr>, ) -> Result<ExprImpl, RwError>
ARRAY[...]
is represented as an function call at the binder stage.
pub(super) fn bind_map( &mut self, entries: Vec<(Expr, Expr)>, ) -> Result<ExprImpl, RwError>
pub(super) fn bind_array_cast( &mut self, exprs: Vec<Expr>, element_type: Box<DataType>, ) -> Result<ExprImpl, RwError>
pub(super) fn bind_map_cast( &mut self, entries: Vec<(Expr, Expr)>, map_type: MapType, ) -> Result<ExprImpl, RwError>
pub(super) fn bind_index( &mut self, obj: Expr, index: Expr, ) -> Result<ExprImpl, RwError>
pub(super) fn bind_array_range_index( &mut self, obj: Expr, start: Option<Box<Expr>>, end: Option<Box<Expr>>, ) -> Result<ExprImpl, RwError>
source§impl Binder
impl Binder
sourcepub fn bind_expr(&mut self, expr: Expr) -> Result<ExprImpl, RwError>
pub fn bind_expr(&mut self, expr: Expr) -> Result<ExprImpl, RwError>
Bind an expression with bind_expr_inner
, attach the original expression
to the error message.
This may only be called at the root of the expression tree or when crossing the boundary of a subquery. Otherwise, the source chain might be too deep and confusing to the user.
fn bind_expr_inner(&mut self, expr: Expr) -> Result<ExprImpl, RwError>
pub(super) fn bind_extract( &mut self, field: String, expr: Expr, ) -> Result<ExprImpl, RwError>
pub(super) fn bind_at_time_zone( &mut self, input: Expr, time_zone: Expr, ) -> Result<ExprImpl, RwError>
pub(super) fn bind_in_list( &mut self, expr: Expr, list: Vec<Expr>, negated: bool, ) -> Result<ExprImpl, RwError>
pub(super) fn bind_in_subquery( &mut self, expr: Expr, subquery: Query, negated: bool, ) -> Result<ExprImpl, RwError>
pub(super) fn bind_is_json( &mut self, expr: Expr, negated: bool, item_type: JsonPredicateType, ) -> Result<ExprImpl, RwError>
pub(super) fn bind_unary_expr( &mut self, op: UnaryOperator, expr: Expr, ) -> Result<ExprImpl, RwError>
sourcefn rewrite_positive(&mut self, expr: Expr) -> Result<ExprImpl, RwError>
fn rewrite_positive(&mut self, expr: Expr) -> Result<ExprImpl, RwError>
Directly returns the expression itself if it is a positive number.
pub(super) fn bind_trim( &mut self, expr: Expr, trim_where: Option<TrimWhereField>, trim_what: Option<Box<Expr>>, ) -> Result<ExprImpl, RwError>
fn bind_substring( &mut self, expr: Expr, substring_from: Option<Box<Expr>>, substring_for: Option<Box<Expr>>, ) -> Result<ExprImpl, RwError>
fn bind_position( &mut self, substring: Expr, string: Expr, ) -> Result<ExprImpl, RwError>
fn bind_overlay( &mut self, expr: Expr, new_substring: Expr, start: Expr, count: Option<Box<Expr>>, ) -> Result<ExprImpl, RwError>
fn bind_parameter(&mut self, index: u64) -> Result<ExprImpl, RwError>
sourcepub(super) fn bind_between(
&mut self,
expr: Expr,
negated: bool,
low: Expr,
high: Expr,
) -> Result<ExprImpl, RwError>
pub(super) fn bind_between( &mut self, expr: Expr, negated: bool, low: Expr, high: Expr, ) -> Result<ExprImpl, RwError>
Bind expr (not) between low and high
fn bind_like( &mut self, expr_type: ExprType, expr: Expr, negated: bool, pattern: Expr, escape_char: Option<EscapeChar>, ) -> Result<ExprImpl, RwError>
sourcepub(super) fn bind_similar_to(
&mut self,
expr: Expr,
negated: bool,
pattern: Expr,
escape_char: Option<EscapeChar>,
) -> Result<ExprImpl, RwError>
pub(super) fn bind_similar_to( &mut self, expr: Expr, negated: bool, pattern: Expr, escape_char: Option<EscapeChar>, ) -> Result<ExprImpl, RwError>
Bind <expr> [ NOT ] SIMILAR TO <pat> ESCAPE <esc_text>
sourcefn check_constant_case_when_optimization(
&mut self,
conditions: Vec<Expr>,
results_expr: Vec<ExprImpl>,
operand: Option<Box<Expr>>,
fallback: Option<ExprImpl>,
constant_case_when_eval_inputs: &mut Vec<ExprImpl>,
) -> bool
fn check_constant_case_when_optimization( &mut self, conditions: Vec<Expr>, results_expr: Vec<ExprImpl>, operand: Option<Box<Expr>>, fallback: Option<ExprImpl>, constant_case_when_eval_inputs: &mut Vec<ExprImpl>, ) -> bool
The optimization check for the following case-when expression pattern e.g., select case 1 when (…) then (…) else (…) end;
sourcefn compare_or_set(col_expr: &mut Option<Expr>, test_expr: Expr) -> bool
fn compare_or_set(col_expr: &mut Option<Expr>, test_expr: Expr) -> bool
Helper function to compare or set column identifier
used in check_convert_simple_form
sourcefn check_invariant(left: Expr, op: BinaryOperator, right: Expr) -> bool
fn check_invariant(left: Expr, op: BinaryOperator, right: Expr) -> bool
left expression and right expression must be either:
<constant> <Eq> <identifier>
or <identifier> <Eq> <constant>
used in check_convert_simple_form
sourcefn try_extract_simple_form(
&mut self,
ident_expr: Expr,
constant_expr: Expr,
column_expr: &mut Option<Expr>,
inputs: &mut Vec<ExprImpl>,
) -> bool
fn try_extract_simple_form( &mut self, ident_expr: Expr, constant_expr: Expr, column_expr: &mut Option<Expr>, inputs: &mut Vec<ExprImpl>, ) -> bool
Helper function to extract expression out and insert
the corresponding bound version to inputs
used in check_convert_simple_form
Note: this function will be invoked per arm
sourcefn check_convert_simple_form(
&mut self,
conditions: Vec<Expr>,
results_expr: Vec<ExprImpl>,
fallback: Option<ExprImpl>,
constant_lookup_inputs: &mut Vec<ExprImpl>,
) -> bool
fn check_convert_simple_form( &mut self, conditions: Vec<Expr>, results_expr: Vec<ExprImpl>, fallback: Option<ExprImpl>, constant_lookup_inputs: &mut Vec<ExprImpl>, ) -> bool
See if the case when expression in form
select case when <expr_1 = constant> (...with same pattern...) else <constant> end;
If so, this expression could also be converted to constant lookup
sourcefn check_bind_case_optimization(
&mut self,
conditions: Vec<Expr>,
results_expr: Vec<ExprImpl>,
operand: Option<Box<Expr>>,
fallback: Option<ExprImpl>,
constant_lookup_inputs: &mut Vec<ExprImpl>,
) -> bool
fn check_bind_case_optimization( &mut self, conditions: Vec<Expr>, results_expr: Vec<ExprImpl>, operand: Option<Box<Expr>>, fallback: Option<ExprImpl>, constant_lookup_inputs: &mut Vec<ExprImpl>, ) -> bool
The helper function to check if the current case-when
expression in bind_case
could be optimized
into ConstantLookupExpression
pub(super) fn bind_case( &mut self, operand: Option<Box<Expr>>, conditions: Vec<Expr>, results: Vec<Expr>, else_result: Option<Box<Expr>>, ) -> Result<ExprImpl, RwError>
pub(super) fn bind_is_operator( &mut self, func_type: ExprType, expr: Expr, ) -> Result<ExprImpl, RwError>
pub(super) fn bind_is_unknown( &mut self, func_type: ExprType, expr: Expr, ) -> Result<ExprImpl, RwError>
pub(super) fn bind_distinct_from( &mut self, left: Expr, right: Expr, ) -> Result<ExprImpl, RwError>
pub(super) fn bind_not_distinct_from( &mut self, left: Expr, right: Expr, ) -> Result<ExprImpl, RwError>
pub(super) fn bind_cast( &mut self, expr: Expr, data_type: AstDataType, ) -> Result<ExprImpl, RwError>
pub fn bind_cast_inner( &mut self, expr: Expr, data_type: DataType, ) -> Result<ExprImpl, RwError>
pub fn bind_collate( &mut self, expr: Expr, collation: ObjectName, ) -> Result<ExprImpl, RwError>
source§impl Binder
impl Binder
pub fn bind_fetch_cursor( &mut self, cursor_name: String, count: u32, returning_schema: Option<Schema>, ) -> Result<BoundFetchCursor, RwError>
source§impl Binder
impl Binder
pub fn bind_sink_by_name(&self, name: ObjectName) -> Result<BoundSink, RwError>
pub fn bind_view_by_name(&self, name: ObjectName) -> Result<BoundView, RwError>
source§impl Binder
impl Binder
pub(super) fn bind_insert( &mut self, name: ObjectName, cols_to_insert_by_user: Vec<Ident>, source: Query, returning_items: Vec<SelectItem>, ) -> Result<BoundInsert, RwError>
sourcepub(super) fn cast_on_insert(
expected_types: &Vec<DataType>,
exprs: Vec<ExprImpl>,
) -> Result<Vec<ExprImpl>, RwError>
pub(super) fn cast_on_insert( expected_types: &Vec<DataType>, exprs: Vec<ExprImpl>, ) -> Result<Vec<ExprImpl>, RwError>
Cast a list of exprs
to corresponding expected_types
IN ASSIGNMENT CONTEXT. Make sure
you understand the difference of implicit, assignment and explicit cast before reusing it.
source§impl Binder
impl Binder
sourcepub fn bind_query(&mut self, query: Query) -> Result<BoundQuery, RwError>
pub fn bind_query(&mut self, query: Query) -> Result<BoundQuery, RwError>
Bind a Query
.
Before binding the Query
, we push the current BindContext
to the
stack and create a new context, because it may be a subquery.
After finishing binding, we pop the previous context from the stack.
sourcepub(super) fn bind_query_inner(
&mut self,
_: Query,
) -> Result<BoundQuery, RwError>
pub(super) fn bind_query_inner( &mut self, _: Query, ) -> Result<BoundQuery, RwError>
Bind a Query
using the current BindContext
.
pub fn build_name_to_index( names: impl Iterator<Item = String>, ) -> HashMap<String, usize>
sourcefn bind_order_by_expr_in_query(
&mut self,
_: OrderByExpr,
name_to_index: &HashMap<String, usize>,
extra_order_exprs: &mut Vec<ExprImpl>,
visible_output_num: usize,
) -> Result<ColumnOrder, RwError>
fn bind_order_by_expr_in_query( &mut self, _: OrderByExpr, name_to_index: &HashMap<String, usize>, extra_order_exprs: &mut Vec<ExprImpl>, visible_output_num: usize, ) -> Result<ColumnOrder, RwError>
Bind an ORDER BY
expression in a Query
, which can be either:
- an output-column name
- index of an output column
- an arbitrary expression
Refer to bind_group_by_expr_in_select
to see their similarities and differences.
§Arguments
name_to_index
- visible output column name -> index. Ambiguous (duplicate) output names are marked withusize::MAX
.visible_output_num
- the number of all visible output columns, including duplicates.
fn bind_with(&mut self, with: With) -> Result<(), RwError>
sourcefn validate_rcte(query: Query) -> Result<(SetExpr, Option<With>), RwError>
fn validate_rcte(query: Query) -> Result<(SetExpr, Option<With>), RwError>
syntactically validate the recursive cte ast with the current support features in rw.
fn bind_rcte( &mut self, with: Option<With>, entry: Rc<RefCell<BindingCte>>, left: SetExpr, right: SetExpr, all: bool, ) -> Result<(), RwError>
fn bind_rcte_inner( &mut self, with: Option<With>, entry: Rc<RefCell<BindingCte>>, left: SetExpr, right: SetExpr, all: bool, ) -> Result<(), RwError>
source§impl Binder
impl Binder
pub(crate) fn bind_vec_table_with_joins( &mut self, from: Vec<TableWithJoins>, ) -> Result<Option<Relation>, RwError>
pub(crate) fn bind_table_with_joins( &mut self, table: TableWithJoins, ) -> Result<Relation, RwError>
fn bind_join_constraint( &mut self, constraint: JoinConstraint, table_factor: Option<TableFactor>, join_type: JoinType, ) -> Result<(ExprImpl, Option<Relation>), RwError>
fn get_identifier_from_indices( context: &BindContext, indices: &[usize], column: Ident, ) -> Result<Expr, RwError>
source§impl Binder
impl Binder
sourcepub(super) fn bind_subquery_relation(
&mut self,
query: Query,
alias: Option<TableAlias>,
lateral: bool,
) -> Result<BoundSubquery, RwError>
pub(super) fn bind_subquery_relation( &mut self, query: Query, alias: Option<TableAlias>, lateral: bool, ) -> Result<BoundSubquery, RwError>
Binds a subquery using bind_query
, which will use a new empty
BindContext
for it.
After finishing binding, we update the current context with the output of the subquery.
source§impl Binder
impl Binder
sourcepub(super) fn bind_table_function(
&mut self,
name: ObjectName,
alias: Option<TableAlias>,
args: Vec<FunctionArg>,
with_ordinality: bool,
) -> Result<Relation, RwError>
pub(super) fn bind_table_function( &mut self, name: ObjectName, alias: Option<TableAlias>, args: Vec<FunctionArg>, with_ordinality: bool, ) -> Result<Relation, RwError>
Binds a table function AST, which is a function call in a relation position.
Besides crate::expr::TableFunction
expr, it can also be other things like window table
functions, or scalar functions.
with_ordinality
is only supported for the TableFunction
case now.
source§impl Binder
impl Binder
sourcepub fn bind_relation_by_name_inner(
&mut self,
schema_name: Option<&str>,
table_name: &str,
alias: Option<TableAlias>,
as_of: Option<AsOf>,
) -> Result<Relation, RwError>
pub fn bind_relation_by_name_inner( &mut self, schema_name: Option<&str>, table_name: &str, alias: Option<TableAlias>, as_of: Option<AsOf>, ) -> Result<Relation, RwError>
Binds table or source, or logical view according to what we get from the catalog.
fn resolve_table_relation( &mut self, table_catalog: Arc<TableCatalog>, schema_name: &str, as_of: Option<AsOf>, ) -> Result<(Relation, Vec<(bool, Field)>), RwError>
fn resolve_source_relation( &mut self, source_catalog: &SourceCatalog, as_of: Option<AsOf>, ) -> (Relation, Vec<(bool, Field)>)
fn resolve_view_relation( &mut self, view_catalog: &ViewCatalog, ) -> Result<(Relation, Vec<(bool, Field)>), RwError>
fn resolve_table_indexes( &self, schema_name: &str, table_id: TableId, ) -> Result<Vec<Arc<IndexCatalog>>, RwError>
pub(crate) fn bind_table( &mut self, schema_name: Option<&str>, table_name: &str, alias: Option<TableAlias>, ) -> Result<BoundBaseTable, RwError>
pub(crate) fn resolve_dml_table<'a>( &'a self, schema_name: Option<&str>, table_name: &str, is_insert: bool, ) -> Result<&'a TableCatalog, RwError>
source§impl Binder
impl Binder
pub(super) fn bind_watermark( &mut self, alias: Option<TableAlias>, args: Vec<FunctionArg>, ) -> Result<BoundWatermark, RwError>
source§impl Binder
impl Binder
pub(super) fn bind_window_table_function( &mut self, alias: Option<TableAlias>, kind: WindowTableFunctionKind, args: Vec<FunctionArg>, ) -> Result<BoundWindowTableFunction, RwError>
source§impl Binder
impl Binder
sourcepub fn resolve_schema_qualified_name(
db_name: &str,
name: ObjectName,
) -> Result<(Option<String>, String), ResolveQualifiedNameError>
pub fn resolve_schema_qualified_name( db_name: &str, name: ObjectName, ) -> Result<(Option<String>, String), ResolveQualifiedNameError>
return (schema_name
, name
)
sourcefn resolve_single_name(
identifiers: Vec<Ident>,
ident_desc: &str,
) -> Result<String, RwError>
fn resolve_single_name( identifiers: Vec<Ident>, ident_desc: &str, ) -> Result<String, RwError>
return first name in identifiers, must have only one name.
sourcepub fn resolve_database_name(name: ObjectName) -> Result<String, RwError>
pub fn resolve_database_name(name: ObjectName) -> Result<String, RwError>
return the database_name
sourcepub fn resolve_schema_name(name: ObjectName) -> Result<String, RwError>
pub fn resolve_schema_name(name: ObjectName) -> Result<String, RwError>
return the schema_name
sourcepub fn resolve_index_name(name: ObjectName) -> Result<String, RwError>
pub fn resolve_index_name(name: ObjectName) -> Result<String, RwError>
return the index_name
sourcepub fn resolve_view_name(name: ObjectName) -> Result<String, RwError>
pub fn resolve_view_name(name: ObjectName) -> Result<String, RwError>
return the view_name
sourcepub fn resolve_sink_name(name: ObjectName) -> Result<String, RwError>
pub fn resolve_sink_name(name: ObjectName) -> Result<String, RwError>
return the sink_name
sourcepub fn resolve_subscription_name(name: ObjectName) -> Result<String, RwError>
pub fn resolve_subscription_name(name: ObjectName) -> Result<String, RwError>
return the subscription_name
sourcepub fn resolve_table_name(name: ObjectName) -> Result<String, RwError>
pub fn resolve_table_name(name: ObjectName) -> Result<String, RwError>
return the table_name
sourcepub fn resolve_source_name(name: ObjectName) -> Result<String, RwError>
pub fn resolve_source_name(name: ObjectName) -> Result<String, RwError>
return the source_name
sourcepub fn resolve_user_name(name: ObjectName) -> Result<String, RwError>
pub fn resolve_user_name(name: ObjectName) -> Result<String, RwError>
return the user_name
sourcepub(super) fn bind_table_to_context(
&mut self,
columns: impl IntoIterator<Item = (bool, Field)>,
table_name: String,
alias: Option<TableAlias>,
) -> Result<(), RwError>
pub(super) fn bind_table_to_context( &mut self, columns: impl IntoIterator<Item = (bool, Field)>, table_name: String, alias: Option<TableAlias>, ) -> Result<(), RwError>
Fill the BindContext
for table.
sourcepub fn bind_relation_by_name(
&mut self,
name: ObjectName,
alias: Option<TableAlias>,
as_of: Option<AsOf>,
) -> Result<Relation, RwError>
pub fn bind_relation_by_name( &mut self, name: ObjectName, alias: Option<TableAlias>, as_of: Option<AsOf>, ) -> Result<Relation, RwError>
Binds a relation, which can be:
- a table/source/materialized view
- a reference to a CTE
- a logical view
fn bind_relation_by_function_arg( &mut self, arg: Option<FunctionArg>, err_msg: &str, ) -> Result<(Relation, ObjectName), RwError>
fn bind_column_by_function_args( &mut self, arg: Option<FunctionArg>, err_msg: &str, ) -> Result<Box<InputRef>, RwError>
sourcefn bind_internal_table(
&mut self,
args: Vec<FunctionArg>,
alias: Option<TableAlias>,
) -> Result<Relation, RwError>
fn bind_internal_table( &mut self, args: Vec<FunctionArg>, alias: Option<TableAlias>, ) -> Result<Relation, RwError>
rw_table(table_id[,schema_name])
which queries internal table
pub(super) fn bind_table_factor( &mut self, table_factor: TableFactor, ) -> Result<Relation, RwError>
source§impl Binder
impl Binder
pub(super) fn bind_select( &mut self, select: Select, ) -> Result<BoundSelect, RwError>
pub fn bind_select_list( &mut self, select_items: Vec<SelectItem>, ) -> Result<(Vec<ExprImpl>, Vec<Option<String>>), RwError>
sourcefn bind_group_by_expr_in_select(
&mut self,
expr: Expr,
name_to_index: &HashMap<String, usize>,
select_items: &[ExprImpl],
) -> Result<ExprImpl, RwError>
fn bind_group_by_expr_in_select( &mut self, expr: Expr, name_to_index: &HashMap<String, usize>, select_items: &[ExprImpl], ) -> Result<ExprImpl, RwError>
Bind an GROUP BY
expression in a Select
, which can be either:
- index of an output column
- an arbitrary expression on input columns
- an output-column name
Note the differences from bind_order_by_expr_in_query
:
- When a name matches both an input column and an output column,
group by
interprets it as input column whileorder by
interprets it as output column. - As the name suggests,
group by
is part ofselect
whileorder by
is part ofquery
. Aquery
may consist unions of multipleselect
s (each with their owngroup by
) but only oneorder by
. - Logically / semantically,
group by
evaluates beforeselect items
, which evaluates beforeorder by
. This means,group by
can evaluate arbitrary expressions itself, or take expressions fromselect items
(weclone
here andlogical_agg
will rewrite thoseselect items
toInputRef
). However,order by
can only refer toselect items
, or append its extra arbitrary expressions as hiddenselect items
for evaluation.
§Arguments
name_to_index
- output column name -> index. Ambiguous (duplicate) output names are marked withusize::MAX
.
fn bind_grouping_items_expr_in_select( &mut self, grouping_items: Vec<Vec<Expr>>, name_to_index: &HashMap<String, usize>, select_items: &[ExprImpl], ) -> Result<Vec<Vec<ExprImpl>>, RwError>
pub fn bind_returning_list( &mut self, returning_items: Vec<SelectItem>, ) -> Result<(Vec<ExprImpl>, Vec<Field>), RwError>
pub fn iter_bound_columns<'a>( column_binding: impl Iterator<Item = &'a ColumnBinding>, ) -> (Vec<ExprImpl>, Vec<Option<String>>)
pub fn iter_column_groups(&self) -> (Vec<ExprImpl>, Vec<Option<String>>)
sourcefn bind_distinct_on(
&mut self,
distinct: Distinct,
name_to_index: &HashMap<String, usize>,
select_items: &[ExprImpl],
) -> Result<BoundDistinct, RwError>
fn bind_distinct_on( &mut self, distinct: Distinct, name_to_index: &HashMap<String, usize>, select_items: &[ExprImpl], ) -> Result<BoundDistinct, RwError>
Bind DISTINCT
clause in a Select
.
Note that for DISTINCT ON
, each expression is interpreted in the same way as ORDER BY
expression, which means it will be bound in the following order:
- as an output-column name (can use aliases)
- as an index (from 1) of an output column
- as an arbitrary expression (cannot use aliases)
See also the bind_order_by_expr_in_query
method.
§Arguments
name_to_index
- output column name -> index. Ambiguous (duplicate) output names are marked withusize::MAX
.
fn generate_except_indices( &mut self, except: Option<Vec<Expr>>, ) -> Result<HashSet<usize>, RwError>
source§impl Binder
impl Binder
sourcepub(crate) fn align_schema(
left: &mut BoundSetExpr,
right: &mut BoundSetExpr,
op: SetOperator,
) -> Result<(), RwError>
pub(crate) fn align_schema( left: &mut BoundSetExpr, right: &mut BoundSetExpr, op: SetOperator, ) -> Result<(), RwError>
note: align_schema
only works when the left
and right
are both select expression(s).
sourcepub(crate) fn validate(
left: &BoundSetExpr,
right: &BoundSetExpr,
op: SetOperator,
) -> Result<(), RwError>
pub(crate) fn validate( left: &BoundSetExpr, right: &BoundSetExpr, op: SetOperator, ) -> Result<(), RwError>
validate the schema, should be called after aligning.
sourcefn corresponding(
&self,
left: &BoundSetExpr,
right: &BoundSetExpr,
corresponding: Corresponding,
op: &SetOperator,
) -> Result<(ColIndexMapping, ColIndexMapping), RwError>
fn corresponding( &self, left: &BoundSetExpr, right: &BoundSetExpr, corresponding: Corresponding, op: &SetOperator, ) -> Result<(ColIndexMapping, ColIndexMapping), RwError>
Check the corresponding specification of the set operation. Returns the corresponding column index of the left and right side.
pub(super) fn bind_set_expr( &mut self, set_expr: SetExpr, ) -> Result<BoundSetExpr, RwError>
source§impl Binder
impl Binder
pub(super) fn bind_statement( &mut self, stmt: Statement, ) -> Result<BoundStatement, RwError>
source§impl Binder
impl Binder
sourcefn extract_struct_column(
&mut self,
expr: Expr,
field_idents: Vec<Ident>,
) -> Result<(ExprImpl, Vec<Ident>), RwError>
fn extract_struct_column( &mut self, expr: Expr, field_idents: Vec<Ident>, ) -> Result<(ExprImpl, Vec<Ident>), RwError>
Extracts and binds struct column from expr
.
Returns the bound column and the remaining fields.
Specifically,
(table).struct_col.fields
->(bound_struct_col, fields)
- Otherwise,
expr
corresponds to a column.(expr).fields
->(bound_expr, fields)
sourcepub fn bind_wildcard_field_column(
&mut self,
expr: Expr,
prefix: Vec<Ident>,
) -> Result<(Vec<ExprImpl>, Vec<Option<String>>), RwError>
pub fn bind_wildcard_field_column( &mut self, expr: Expr, prefix: Vec<Ident>, ) -> Result<(Vec<ExprImpl>, Vec<Option<String>>), RwError>
Binds wildcard field column, e.g. (table.v1).*
or (table).v1.*
.
Returns a vector of Field(expr, int)
expressions and aliases.
sourcepub fn bind_single_field_column(
&mut self,
expr: Expr,
idents: &[Ident],
) -> Result<ExprImpl, RwError>
pub fn bind_single_field_column( &mut self, expr: Expr, idents: &[Ident], ) -> Result<ExprImpl, RwError>
Binds single field column, e.g. (table.v1).v2
or (table).v1.v2
.
Returns a Field(expr, int)
expression.
source§impl Binder
impl Binder
pub(super) fn bind_update( &mut self, name: ObjectName, assignments: Vec<Assignment>, selection: Option<Expr>, returning_items: Vec<SelectItem>, ) -> Result<BoundUpdate, RwError>
source§impl Binder
impl Binder
sourcepub(super) fn bind_values(
&mut self,
values: Values,
expected_types: Option<Vec<DataType>>,
) -> Result<BoundValues, RwError>
pub(super) fn bind_values( &mut self, values: Values, expected_types: Option<Vec<DataType>>, ) -> Result<BoundValues, RwError>
Bind Values
with given expected_types
. If no types are expected, a compatible type for
all rows will be used.
If values are shorter than expected, NULL
s will be filled.
source§impl Binder
impl Binder
fn new_inner( session: &SessionImpl, bind_for: BindFor, param_types: Vec<Option<DataType>>, ) -> Binder
pub fn new(session: &SessionImpl) -> Binder
pub fn new_with_param_types( session: &SessionImpl, param_types: Vec<Option<DataType>>, ) -> Binder
pub fn new_for_stream(session: &SessionImpl) -> Binder
pub fn new_for_ddl(session: &SessionImpl) -> Binder
pub fn new_for_system(session: &SessionImpl) -> Binder
pub fn new_for_stream_with_param_types( session: &SessionImpl, param_types: Vec<Option<DataType>>, ) -> Binder
fn is_for_stream(&self) -> bool
fn is_for_batch(&self) -> bool
fn is_for_ddl(&self) -> bool
pub fn export_param_types(&self) -> Result<Vec<DataType>, RwError>
sourcepub fn included_relations(&self) -> &HashSet<TableId>
pub fn included_relations(&self) -> &HashSet<TableId>
Get included relations in the query after binding. This is used for resolving relation dependencies. Note that it only contains referenced relations discovered during binding. After the plan is built, the referenced relations may be changed. We cannot rely on the collection result of plan, because we still need to record the dependencies that have been optimised away.
sourcepub fn included_udfs(&self) -> &HashSet<FunctionId>
pub fn included_udfs(&self) -> &HashSet<FunctionId>
Get included user-defined functions in the query after binding.
fn push_context(&mut self)
fn pop_context(&mut self) -> Result<(), RwError>
fn push_lateral_context(&mut self)
fn pop_and_merge_lateral_context(&mut self) -> Result<(), RwError>
fn try_mark_lateral_as_visible(&mut self)
fn try_mark_lateral_as_invisible(&mut self)
fn next_subquery_id(&mut self) -> usize
fn next_values_id(&mut self) -> usize
fn first_valid_schema(&self) -> Result<&SchemaCatalog, CatalogError>
pub fn set_clause(&mut self, clause: Option<Clause>)
pub fn udf_context_mut(&mut self) -> &mut UdfContext
Auto Trait Implementations§
impl Freeze for Binder
impl !RefUnwindSafe for Binder
impl !Send for Binder
impl !Sync for Binder
impl Unpin for Binder
impl !UnwindSafe for Binder
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
§impl<T> Conv for T
impl<T> Conv for T
§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
§impl<T, U, I> LiftInto<U, I> for Twhere
U: LiftFrom<T, I>,
impl<T, U, I> LiftInto<U, I> for Twhere
U: LiftFrom<T, I>,
source§impl<M> MetricVecRelabelExt for M
impl<M> MetricVecRelabelExt for M
source§fn relabel(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level
.source§fn relabel_n(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
relabel_num: usize,
) -> RelabeledMetricVec<M>
fn relabel_n( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, relabel_num: usize, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level_relabel_n
.source§fn relabel_debug_1(
self,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel_debug_1( self, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level_relabel_n
with metric_level
set to
MetricLevel::Debug
and relabel_num
set to 1.§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<Source> Sculptor<HNil, HNil> for Source
impl<Source> Sculptor<HNil, HNil> for Source
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.