Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions datafusion/expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,7 @@ impl Expr {
}

/// Return all referenced columns of this expression.
#[deprecated(since = "40.0.0", note = "use Expr::column_refs instead")]
pub fn to_columns(&self) -> Result<HashSet<Column>> {
let mut using_columns = HashSet::new();
expr_to_columns(self, &mut using_columns)?;
Expand Down
9 changes: 6 additions & 3 deletions datafusion/expr/src/logical_plan/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ use crate::logical_plan::{
use crate::type_coercion::binary::{comparison_coercion, values_coercion};
use crate::utils::{
can_hash, columnize_expr, compare_sort_expr, expand_qualified_wildcard,
expand_wildcard, find_valid_equijoin_key_pair, group_window_expr_by_sort_keys,
expand_wildcard, expr_to_columns, find_valid_equijoin_key_pair,
group_window_expr_by_sort_keys,
};
use crate::{
and, binary_expr, logical_plan::tree_node::unwrap_arc, DmlStatement, Expr,
Expand Down Expand Up @@ -1070,14 +1071,16 @@ impl LogicalPlanBuilder {
let left_key = l.into();
let right_key = r.into();

let left_using_columns = left_key.to_columns()?;
let mut left_using_columns = HashSet::new();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried several ways to avoid copying Columns here -- and I could not. Note that normalize_col_with_schemas_and_ambiguity_check takes left_key by move, so we can't simply call left_key.column_refs() as we can't move left_key when borrowed

expr_to_columns(&left_key, &mut left_using_columns)?;
let normalized_left_key = normalize_col_with_schemas_and_ambiguity_check(
left_key,
&[&[self.plan.schema(), right.schema()]],
&[left_using_columns],
)?;

let right_using_columns = right_key.to_columns()?;
let mut right_using_columns = HashSet::new();
expr_to_columns(&right_key, &mut right_using_columns)?;
let normalized_right_key = normalize_col_with_schemas_and_ambiguity_check(
right_key,
&[&[self.plan.schema(), right.schema()]],
Expand Down