MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / plan_table_factor

Function plan_table_factor

src/sql/src/plan/query.rs:2987–3039  ·  view source on GitHub ↗
(
    qcx: &QueryContext,
    table_factor: &TableFactor<Aug>,
)

Source from the content-addressed store, hash-verified

2985}
2986
2987fn plan_table_factor(
2988 qcx: &QueryContext,
2989 table_factor: &TableFactor<Aug>,
2990) -> Result<(HirRelationExpr, Scope), PlanError> {
2991 match table_factor {
2992 TableFactor::Table { name, alias } => {
2993 let (expr, scope) = qcx.resolve_table_name(name.clone())?;
2994 let scope = plan_table_alias(scope, alias.as_ref())?;
2995 Ok((expr, scope))
2996 }
2997
2998 TableFactor::Function {
2999 function,
3000 alias,
3001 with_ordinality,
3002 } => plan_solitary_table_function(qcx, function, alias.as_ref(), *with_ordinality),
3003
3004 TableFactor::RowsFrom {
3005 functions,
3006 alias,
3007 with_ordinality,
3008 } => plan_rows_from(qcx, functions, alias.as_ref(), *with_ordinality),
3009
3010 TableFactor::Derived {
3011 lateral,
3012 subquery,
3013 alias,
3014 } => {
3015 let mut qcx = (*qcx).clone();
3016 if !lateral {
3017 // Since this derived table was not marked as `LATERAL`,
3018 // make elements in outer scopes invisible until we reach the
3019 // next lateral barrier.
3020 for scope in &mut qcx.outer_scopes {
3021 if scope.lateral_barrier {
3022 break;
3023 }
3024 scope.items.clear();
3025 }
3026 }
3027 qcx.outer_scopes[0].lateral_barrier = true;
3028 let (expr, scope) = plan_nested_query(&mut qcx, subquery)?;
3029 let scope = plan_table_alias(scope, alias.as_ref())?;
3030 Ok((expr, scope))
3031 }
3032
3033 TableFactor::NestedJoin { join, alias } => {
3034 let (expr, scope) = plan_table_with_joins(qcx, join)?;
3035 let scope = plan_table_alias(scope, alias.as_ref())?;
3036 Ok((expr, scope))
3037 }
3038 }
3039}
3040
3041/// Plans a `ROWS FROM` expression.
3042///

Callers 2

plan_table_with_joinsFunction · 0.85
plan_joinFunction · 0.85

Calls 9

plan_table_aliasFunction · 0.85
plan_rows_fromFunction · 0.85
plan_nested_queryFunction · 0.85
plan_table_with_joinsFunction · 0.85
resolve_table_nameMethod · 0.80
cloneMethod · 0.45
as_refMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected