Recursively identify all Column expressions and transform them into the appropriate window expression contained in window. For example, if expr contains the column expr "COUNT(*) PARTITION BY id" it will be transformed into an actual window expression as identified in the window node.
(expr: Expr, windows: &[&Window])
| 251 | /// For example, if expr contains the column expr "COUNT(*) PARTITION BY id" it will be transformed |
| 252 | /// into an actual window expression as identified in the window node. |
| 253 | pub(crate) fn unproject_window_exprs(expr: Expr, windows: &[&Window]) -> Result<Expr> { |
| 254 | expr.transform(|sub_expr| { |
| 255 | if let Expr::Column(c) = sub_expr { |
| 256 | if let Some(unproj) = find_window_expr(windows, &c.name) { |
| 257 | Ok(Transformed::yes(unproj.clone())) |
| 258 | } else { |
| 259 | Ok(Transformed::no(Expr::Column(c))) |
| 260 | } |
| 261 | } else { |
| 262 | Ok(Transformed::no(sub_expr)) |
| 263 | } |
| 264 | }) |
| 265 | .map(|e| e.data) |
| 266 | } |
| 267 | |
| 268 | fn find_agg_expr<'a>(agg: &'a Aggregate, column: &Column) -> Result<Option<&'a Expr>> { |
| 269 | if let Ok(index) = agg.schema.index_of_column(column) { |
no test coverage detected
searching dependent graphs…