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

Remove redundant unalias_nested calls for creating Filter's #11340

Merged
merged 4 commits into from
Jul 10, 2024

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Jul 8, 2024

Which issue does this PR close?

Closes #11339

Rationale for this change

In #11307 we changed Filter to remove any aliases within the expressions.

Thus it is no longer necessary to unalias the expressions prior to calling Filter::try_new

What changes are included in this PR?

  1. Remove the unalias_nested calls when calling Filter::try_new()

Are these changes tested?

By existing CI

Are there any user-facing changes?

No

@github-actions github-actions bot added logical-expr Logical plan and expressions optimizer Optimizer rules labels Jul 8, 2024
@alamb alamb marked this pull request as ready for review July 8, 2024 20:40
@@ -645,39 +643,6 @@ impl LogicalPlan {
Ok(LogicalPlan::Values(Values { schema, values }))
}
LogicalPlan::Filter(Filter { predicate, input }) => {
// todo: should this logic be moved to Filter::try_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.

this PR completes this TODO, per @jonahgao 's suggestion

@@ -761,11 +761,11 @@ impl OptimizerRule for PushDownFilter {

// Push down non-unnest filter predicate
// Unnest
// Unenst Input (Projection)
// Unnest Input (Projection)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

drive by typo fixup

Copy link
Member

@jonahgao jonahgao left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks @alamb

.update_data(|new_predicate| (new_predicate, new_input));
Ok(new_predicate)
let new_predicate = new_expr.pop().unwrap();
// the closure didn't transform the expr, but will be
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to remove transform_data?

self.try_unary_plan(expr, input, config)?
            .map_data(|(mut new_expr, new_input)| {
                assert_eq!(new_expr.len(), 1); // passed in vec![predicate]
                let new_predicate = new_expr.pop().unwrap();
                Filter::try_new(new_predicate, Arc::new(new_input))
                    .map(LogicalPlan::Filter)
            })

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is an excellent idea. It was -- done in 49d206e

@jonahgao jonahgao merged commit 16a3148 into apache:main Jul 10, 2024
23 checks passed
@alamb alamb deleted the allow-predicate-alias branch July 10, 2024 10:12
@alamb
Copy link
Contributor Author

alamb commented Jul 10, 2024

Thanks again @jonahgao

findepi pushed a commit to findepi/datafusion that referenced this pull request Jul 16, 2024
…#11340)

* Remove uncessary unalias_nested calls when creating Filter

* simplify
xinlifoobar pushed a commit to xinlifoobar/datafusion that referenced this pull request Jul 18, 2024
…#11340)

* Remove uncessary unalias_nested calls when creating Filter

* simplify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logical-expr Logical plan and expressions optimizer Optimizer rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove uncessary unalias_nested calls when creating a logical plan
2 participants