Skip to content

Conversation

@Lordworms
Copy link
Contributor

Which issue does this PR close?

part of #9637

Closes #.

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added the optimizer Optimizer rules label Apr 21, 2024
)?;

let optimized_plan = (!equijoin_predicates.is_empty()).then(|| {
let mut new_on = on.clone();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

here to avoid clone of vector on

Comment on lines -84 to -86
left: left.clone(),
right: right.clone(),
on: new_on,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

here to avoid clone of arc

}

fn split_eq_and_noneq_join_predicate(
filter: &Expr,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

here we directly split filter to avoid further clone

if can_hash(&left_expr_type) && can_hash(&right_expr_type) {
accum_join_keys.push((left_expr, right_expr));
} else {
accum_filters.push(expr.clone());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

avoid clone

"extract_equijoin_predicate"
}
/// split with ownership
fn split_conjunction_own(expr: Expr) -> Vec<Expr> {
Copy link
Contributor Author

@Lordworms Lordworms Apr 21, 2024

Choose a reason for hiding this comment

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

here implement a ownership version of split conjunction to avoid clone while passing reference

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok got it

@Lordworms Lordworms marked this pull request as ready for review April 21, 2024 22:31
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks @Lordworms -- I think this PR looks very good 👌 .

I left a few suggestions that I think could make it better if you have some time. Otherwise we can do them as follow on PRs

"extract_equijoin_predicate"
}
/// split with ownership
fn split_conjunction_own(expr: Expr) -> Vec<Expr> {
Copy link
Contributor

Choose a reason for hiding this comment

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

join_constraint,
schema,
null_equals_null,
}) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

You might be able to avoid a level of indenting if you did the entire match here, like:

 match plan {
            LogicalPlan::Join(Join {
                left,
                right,
                mut on,
                filter: Some(expr),
                join_type,
                join_constraint,
            }) => {

Then you could avoid reassembling LogicalPlan::Join as well

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks again @Lordworms

@alamb alamb merged commit d9ebd2b into apache:main Apr 22, 2024
ccciudatu pushed a commit to hstack/datafusion that referenced this pull request Apr 26, 2024
…ter (apache#10165)

* implement rewrite for ExtractEquijoinPredicate and avoid clone in filter

* fix clippy

* optimize code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimizer Optimizer rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants