MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / analyse_lateral_where

Function analyse_lateral_where

nodedb-sql/src/planner/lateral/correlation.rs:40–57  ·  view source on GitHub ↗

Analyse the WHERE clause of a LATERAL subquery. `outer_alias` is the alias or name of the driving table (e.g. `"u"` for `FROM users u`). Any compound identifier `outer_alias.col` or `col = outer_alias.col` is treated as a correlation reference to the outer side.

(subquery: &ast::Query, outer_alias: &str)

Source from the content-addressed store, hash-verified

38/// `FROM users u`). Any compound identifier `outer_alias.col` or `col = outer_alias.col`
39/// is treated as a correlation reference to the outer side.
40pub fn analyse_lateral_where(subquery: &ast::Query, outer_alias: &str) -> CorrelationAnalysis {
41 let select = match subquery.body.as_ref() {
42 SetExpr::Select(s) => s,
43 _ => return CorrelationAnalysis::default(),
44 };
45 let Some(where_expr) = &select.selection else {
46 return CorrelationAnalysis::default();
47 };
48
49 let mut analysis = CorrelationAnalysis::default();
50 analysis.remaining = extract_correlation_recursive(
51 where_expr,
52 outer_alias,
53 &mut analysis.equi_keys,
54 &mut analysis.non_equi,
55 );
56 analysis
57}
58
59/// Walk the WHERE expression, extracting correlated predicates.
60///

Callers 1

plan_lateral_joinFunction · 0.85

Calls 2

as_refMethod · 0.45

Tested by

no test coverage detected