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

Function collect_named_windows

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

Build the `WINDOW AS ` definition map (names normalised). References between definitions are resolved lazily on use.

(
    defs: &[ast::NamedWindowDefinition],
)

Source from the content-addressed store, hash-verified

27/// Build the `WINDOW <name> AS <expr>` definition map (names normalised).
28/// References between definitions are resolved lazily on use.
29pub(super) fn collect_named_windows(
30 defs: &[ast::NamedWindowDefinition],
31) -> Result<HashMap<String, &ast::NamedWindowExpr>> {
32 let mut map: HashMap<String, &ast::NamedWindowExpr> = HashMap::with_capacity(defs.len());
33 for ast::NamedWindowDefinition(ident, expr) in defs {
34 let name = normalize_ident(ident);
35 if map.insert(name.clone(), expr).is_some() {
36 return Err(SqlError::Unsupported {
37 detail: format!("duplicate WINDOW definition '{name}'"),
38 });
39 }
40 }
41 Ok(map)
42}
43
44/// Resolve a named-window reference to its concrete `WindowSpec`, following
45/// `WINDOW a AS b` aliases. `seen` tracks the alias chain for cycle

Callers 1

extract_window_functionsFunction · 0.85

Calls 4

normalize_identFunction · 0.85
lenMethod · 0.45
insertMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected