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

Function extract_window_functions

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

Extract window function specifications from a SELECT's projection.

(
    select: &ast::Select,
    functions: &FunctionRegistry,
)

Source from the content-addressed store, hash-verified

26
27/// Extract window function specifications from a SELECT's projection.
28pub fn extract_window_functions(
29 select: &ast::Select,
30 functions: &FunctionRegistry,
31) -> Result<Vec<WindowSpec>> {
32 let named = collect_named_windows(&select.named_window)?;
33 let mut specs = Vec::new();
34 for item in &select.projection {
35 let (expr, alias) = match item {
36 ast::SelectItem::UnnamedExpr(e) => (e, format!("{e}")),
37 ast::SelectItem::ExprWithAlias { expr, alias } => (expr, normalize_ident(alias)),
38 _ => continue,
39 };
40 if let ast::Expr::Function(func) = expr
41 && func.over.is_some()
42 {
43 specs.push(convert_window_spec(func, &alias, functions, &named)?);
44 }
45 }
46 Ok(specs)
47}
48
49fn convert_window_spec(
50 func: &ast::Function,

Calls 4

collect_named_windowsFunction · 0.85
normalize_identFunction · 0.85
convert_window_specFunction · 0.85
pushMethod · 0.45