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

Function walk_relation

src/sql/src/plan/transform_hir.rs:61–94  ·  view source on GitHub ↗
(expr: &mut HirRelationExpr)

Source from the content-addressed store, hash-verified

59/// subquery, especially when the original conjunction contains join keys.
60pub fn split_subquery_predicates(expr: &mut HirRelationExpr) -> Result<(), RecursionLimitError> {
61 fn walk_relation(expr: &mut HirRelationExpr) -> Result<(), RecursionLimitError> {
62 #[allow(deprecated)]
63 expr.visit_mut_fallible(0, &mut |expr, _| {
64 match expr {
65 HirRelationExpr::Map { scalars, .. } => {
66 for scalar in scalars {
67 walk_scalar(scalar)?;
68 }
69 }
70 HirRelationExpr::CallTable { exprs, .. } => {
71 for expr in exprs {
72 walk_scalar(expr)?;
73 }
74 }
75 HirRelationExpr::Filter { predicates, .. } => {
76 let mut subqueries = vec![];
77 for predicate in &mut *predicates {
78 walk_scalar(predicate)?;
79 extract_conjuncted_subqueries(predicate, &mut subqueries)?;
80 }
81 // TODO(benesch): we could be smarter about the order in which
82 // we emit subqueries. At the moment we just emit in the order
83 // we discovered them, but ideally we'd emit them in an order
84 // that accounted for their cost/selectivity. E.g., low-cost,
85 // high-selectivity subqueries should go first.
86 for subquery in subqueries {
87 predicates.push(subquery);
88 }
89 }
90 _ => (),
91 }
92 Ok(())
93 })
94 }
95
96 fn walk_scalar(expr: &mut HirScalarExpr) -> Result<(), RecursionLimitError> {
97 expr.try_visit_direct_subqueries_mut(&mut walk_relation)

Callers 3

walk_scalarFunction · 0.85

Calls 11

walk_scalarFunction · 0.85
visit_mut_fallibleMethod · 0.80
to_vecMethod · 0.80
expectMethod · 0.80
visit1_mutMethod · 0.80
pushMethod · 0.45
insertMethod · 0.45
typMethod · 0.45
cloneMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected