Convert an expression into Column expression if it's already provided as input plan. For example, it rewrites: ```text .aggregate(vec![col("c1")], vec![sum(col("c2"))])? .project(vec![col("c1"), sum(col("c2"))? ``` Into: ```text .aggregate(vec![col("c1")], vec![sum(col("c2"))])? .project(vec![col("c1"), col("SUM(c2)")? ```
(e: Expr, input: &LogicalPlan)
| 780 | /// .project(vec![col("c1"), col("SUM(c2)")? |
| 781 | /// ``` |
| 782 | pub fn columnize_expr(e: Expr, input: &LogicalPlan) -> Result<Expr> { |
| 783 | let output_exprs = match input.columnized_output_exprs() { |
| 784 | Ok(exprs) if !exprs.is_empty() => exprs, |
| 785 | _ => return Ok(e), |
| 786 | }; |
| 787 | let exprs_map: HashMap<&Expr, Column> = output_exprs.into_iter().collect(); |
| 788 | e.transform_down(|node: Expr| match exprs_map.get(&node) { |
| 789 | Some(column) => Ok(Transformed::new( |
| 790 | Expr::Column(column.clone()), |
| 791 | true, |
| 792 | TreeNodeRecursion::Jump, |
| 793 | )), |
| 794 | None => Ok(Transformed::no(node)), |
| 795 | }) |
| 796 | .data() |
| 797 | } |
| 798 | |
| 799 | /// Collect all deeply nested `Expr::Column`'s. They are returned in order of |
| 800 | /// appearance (depth first), and may contain duplicates. |
no test coverage detected
searching dependent graphs…