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

Function resolve_named_def

nodedb-sql/src/planner/window/named.rs:47–68  ·  view source on GitHub ↗

Resolve a named-window reference to its concrete `WindowSpec`, following `WINDOW a AS b` aliases. `seen` tracks the alias chain for cycle detection. Errors on undefined names and cycles.

(
    name: &str,
    named: &HashMap<String, &'a ast::NamedWindowExpr>,
    seen: &mut Vec<String>,
)

Source from the content-addressed store, hash-verified

45/// `WINDOW a AS b` aliases. `seen` tracks the alias chain for cycle
46/// detection. Errors on undefined names and cycles.
47pub(super) fn resolve_named_def<'a>(
48 name: &str,
49 named: &HashMap<String, &'a ast::NamedWindowExpr>,
50 seen: &mut Vec<String>,
51) -> Result<&'a ast::WindowSpec> {
52 let expr = *named.get(name).ok_or_else(|| SqlError::InvalidFunction {
53 detail: format!("window '{name}' is not defined in the WINDOW clause"),
54 })?;
55 match expr {
56 ast::NamedWindowExpr::WindowSpec(spec) => Ok(spec),
57 ast::NamedWindowExpr::NamedWindow(other) => {
58 let other = normalize_ident(other);
59 if seen.contains(&other) {
60 return Err(SqlError::Unsupported {
61 detail: format!("circular WINDOW definition involving '{other}'"),
62 });
63 }
64 seen.push(other.clone());
65 resolve_named_def(&other, named, seen)
66 }
67 }
68}
69
70/// Flatten an inline-or-named `WindowSpec`, merging in any referenced window
71/// per the SQL inheritance rules (see module docs).

Callers 2

flatten_window_specFunction · 0.85
convert_window_specFunction · 0.85

Calls 5

normalize_identFunction · 0.85
getMethod · 0.45
containsMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected