Skip to content

Commit

Permalink
Minor: remove unused methods in datafusion/optimizer/src/utils.rs (#5098
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ygf11 authored Jan 28, 2023
1 parent 0ef2a3a commit 3da801d
Showing 1 changed file with 1 addition and 55 deletions.
56 changes: 1 addition & 55 deletions datafusion/optimizer/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -412,60 +412,6 @@ pub fn only_or_err<T>(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<Column>, Vec<Column>) {
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::<Vec<_>>();
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<Column> {
cols.iter()
.map(|it| Column {
relation: Some(new_table.to_string()),
name: it.name.clone(),
})
.collect()
}

pub fn alias_cols(cols: &[Column]) -> Vec<Expr> {
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.
///
Expand Down

0 comments on commit 3da801d

Please sign in to comment.