MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / plan_window_function_non_aggr

Function plan_window_function_non_aggr

src/sql/src/plan/query.rs:5824–5881  ·  view source on GitHub ↗

The common part of the planning of non-aggregate window functions, i.e., scalar window functions and value window functions.

(
    ecx: &ExprContext,
    Function {
        name,
        args,
        filter,
        over,
        distinct,
    }: &'a Function<Aug>,
)

Source from the content-addressed store, hash-verified

5822/// The common part of the planning of non-aggregate window functions, i.e.,
5823/// scalar window functions and value window functions.
5824fn plan_window_function_non_aggr<'a>(
5825 ecx: &ExprContext,
5826 Function {
5827 name,
5828 args,
5829 filter,
5830 over,
5831 distinct,
5832 }: &'a Function<Aug>,
5833) -> Result<
5834 (
5835 bool,
5836 Vec<HirScalarExpr>,
5837 Vec<ColumnOrder>,
5838 mz_expr::WindowFrame,
5839 Vec<HirScalarExpr>,
5840 Vec<CoercibleScalarExpr>,
5841 ),
5842 PlanError,
5843> {
5844 let (ignore_nulls, order_by_exprs, col_orders, window_frame, partition) =
5845 plan_window_function_common(ecx, name, over)?;
5846
5847 if *distinct {
5848 sql_bail!(
5849 "DISTINCT specified, but {} is not an aggregate function",
5850 name
5851 );
5852 }
5853
5854 if filter.is_some() {
5855 bail_unsupported!("FILTER in non-aggregate window functions");
5856 }
5857
5858 let scalar_args = match &args {
5859 FunctionArgs::Star => {
5860 sql_bail!("* argument is invalid with non-aggregate function {}", name)
5861 }
5862 FunctionArgs::Args { args, order_by } => {
5863 if !order_by.is_empty() {
5864 sql_bail!(
5865 "ORDER BY specified, but {} is not an aggregate function",
5866 name
5867 );
5868 }
5869 plan_exprs(ecx, args)?
5870 }
5871 };
5872
5873 Ok((
5874 ignore_nulls,
5875 order_by_exprs,
5876 col_orders,
5877 window_frame,
5878 partition,
5879 scalar_args,
5880 ))
5881}

Callers 1

plan_functionFunction · 0.85

Calls 4

plan_exprsFunction · 0.85
is_someMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected