Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor: remove unused methods in datafusion/optimizer/src/utils.rs #5098

Merged
merged 1 commit into from
Jan 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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