Build the `WINDOW AS ` definition map (names normalised). References between definitions are resolved lazily on use.
(
defs: &[ast::NamedWindowDefinition],
)
| 27 | /// Build the `WINDOW <name> AS <expr>` definition map (names normalised). |
| 28 | /// References between definitions are resolved lazily on use. |
| 29 | pub(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 |
no test coverage detected