From 0cd933f13211c886bd3cdac226bd2eac16afb435 Mon Sep 17 00:00:00 2001 From: ygf11 Date: Sat, 28 Jan 2023 06:23:06 -0500 Subject: [PATCH] Minor: remove unused methods in datafusion/optimizer/src/utils.rs --- datafusion/optimizer/src/utils.rs | 56 +------------------------------ 1 file changed, 1 insertion(+), 55 deletions(-) diff --git a/datafusion/optimizer/src/utils.rs b/datafusion/optimizer/src/utils.rs index 4ac337ec21de..4b09ab9562c3 100644 --- a/datafusion/optimizer/src/utils.rs +++ b/datafusion/optimizer/src/utils.rs @@ -24,7 +24,7 @@ use datafusion_expr::expr::{BinaryExpr, Sort}; use datafusion_expr::expr_rewriter::{ExprRewritable, ExprRewriter}; use datafusion_expr::expr_visitor::inspect_expr_pre; use datafusion_expr::{ - and, col, + and, logical_plan::{Filter, LogicalPlan}, utils::from_plan, Expr, Operator, @@ -412,60 +412,6 @@ pub fn only_or_err(slice: &[T]) -> Result<&T> { } } -/// Merge and deduplicate two sets Column slices -/// -/// # Arguments -/// -/// * `a` - A tuple of slices of Columns -/// * `b` - A tuple of slices of Columns -/// -/// # Return value -/// -/// The deduplicated union of the two slices -pub fn merge_cols( - a: (&[Column], &[Column]), - b: (&[Column], &[Column]), -) -> (Vec, Vec) { - let e = - a.0.iter() - .map(|it| it.flat_name()) - .chain(a.1.iter().map(|it| it.flat_name())) - .map(|it| Column::from(it.as_str())); - let f = - b.0.iter() - .map(|it| it.flat_name()) - .chain(b.1.iter().map(|it| it.flat_name())) - .map(|it| Column::from(it.as_str())); - let mut g = e.zip(f).collect::>(); - g.dedup(); - g.into_iter().unzip() -} - -/// Change the relation on a slice of Columns -/// -/// # Arguments -/// -/// * `new_table` - The table/relation for the new columns -/// * `cols` - A slice of Columns -/// -/// # Return value -/// -/// A new slice of columns, now belonging to the new table -pub fn swap_table(new_table: &str, cols: &[Column]) -> Vec { - cols.iter() - .map(|it| Column { - relation: Some(new_table.to_string()), - name: it.name.clone(), - }) - .collect() -} - -pub fn alias_cols(cols: &[Column]) -> Vec { - cols.iter() - .map(|it| col(it.flat_name().as_str()).alias(it.name.as_str())) - .collect() -} - /// Rewrites `expr` using `rewriter`, ensuring that the output has the /// same name as `expr` prior to rewrite, adding an alias if necessary. ///