The common part of the planning of all window functions.
(
ecx: &ExprContext,
name: &<Aug as AstInfo>::ItemName,
over: &Option<WindowSpec<Aug>>,
)
| 5882 | |
| 5883 | /// The common part of the planning of all window functions. |
| 5884 | fn plan_window_function_common( |
| 5885 | ecx: &ExprContext, |
| 5886 | name: &<Aug as AstInfo>::ItemName, |
| 5887 | over: &Option<WindowSpec<Aug>>, |
| 5888 | ) -> Result< |
| 5889 | ( |
| 5890 | bool, |
| 5891 | Vec<HirScalarExpr>, |
| 5892 | Vec<ColumnOrder>, |
| 5893 | mz_expr::WindowFrame, |
| 5894 | Vec<HirScalarExpr>, |
| 5895 | ), |
| 5896 | PlanError, |
| 5897 | > { |
| 5898 | if !ecx.allow_windows { |
| 5899 | sql_bail!( |
| 5900 | "window functions are not allowed in {} (function {})", |
| 5901 | ecx.name, |
| 5902 | name |
| 5903 | ); |
| 5904 | } |
| 5905 | |
| 5906 | let window_spec = match over.as_ref() { |
| 5907 | Some(over) => over, |
| 5908 | None => sql_bail!("window function {} requires an OVER clause", name), |
| 5909 | }; |
| 5910 | if window_spec.ignore_nulls && window_spec.respect_nulls { |
| 5911 | sql_bail!("Both IGNORE NULLS and RESPECT NULLS were given."); |
| 5912 | } |
| 5913 | let window_frame = match window_spec.window_frame.as_ref() { |
| 5914 | Some(frame) => plan_window_frame(frame)?, |
| 5915 | None => mz_expr::WindowFrame::default(), |
| 5916 | }; |
| 5917 | let mut partition = Vec::new(); |
| 5918 | for expr in &window_spec.partition_by { |
| 5919 | partition.push(plan_expr(ecx, expr)?.type_as_any(ecx)?); |
| 5920 | } |
| 5921 | |
| 5922 | let (order_by_exprs, col_orders) = plan_function_order_by(ecx, &window_spec.order_by)?; |
| 5923 | |
| 5924 | Ok(( |
| 5925 | window_spec.ignore_nulls, |
| 5926 | order_by_exprs, |
| 5927 | col_orders, |
| 5928 | window_frame, |
| 5929 | partition, |
| 5930 | )) |
| 5931 | } |
| 5932 | |
| 5933 | fn plan_window_frame( |
| 5934 | WindowFrame { |
no test coverage detected