Skip to content

Conversation

@alamb
Copy link
Contributor

@alamb alamb commented Aug 24, 2023

Which issue does this PR close?

related to #7359

Rationale for this change

While reviewing a great documentation improvement from @tshauck it took me a while to find the from_plan function used to rewrite LogicalPlans. See #7359 (comment)

I think this makes it harder to work with the DataFusion codebase unnecessarily.

The reason it took me a while to find I think was

  1. Isn't method on LogicalPlan (it is in a utility module).
  2. It didn't have expr or exprs in its name

Thus, given it takes a &LogicalPlan as its first input I think it makes sense and would be more easily findable as a method on LogicalPlan.

It also turns out from_plan forces Exprs to be copied even when most callsites already have a copy of those exprs

What changes are included in this PR?

  1. Move from from_plan to LogicalPlan::with_new_exprs()
  2. deprecate from_plan
  3. Avoid a copy in new_with_exprs (see second commit in this PR)

Note that LogicalPlan::new_with_exprs take a Vec<Expr> instead of &[Expr] like from_plan as it needs the owned Exprs anyways

Are these changes tested?

By existing tests

Are there any user-facing changes?

New API, deprecated old one

@github-actions github-actions bot added logical-expr Logical plan and expressions optimizer Optimizer rules labels Aug 24, 2023
@alamb alamb self-assigned this Aug 24, 2023
@alamb alamb force-pushed the alamb/from_plan_move branch from 7bd45e4 to 15dfbbd Compare August 24, 2023 17:35
@alamb alamb marked this pull request as ready for review August 25, 2023 13:32
Copy link
Contributor

@tshauck tshauck left a comment

Choose a reason for hiding this comment

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

This seems like a nice refactor from my point of view... it would've helped me find the functionality initially.

It'd also be nice to merge this (or decide not to) so the library docs can be kept correct relative to the underlying code.

@alamb
Copy link
Contributor Author

alamb commented Sep 5, 2023

@liukun4515 / @jackwener could I trouble you for a review of this PR? I can no longer merge such PRs without an approval of another committer.

Thank you, Andrew

Copy link
Member

@jackwener jackwener left a comment

Choose a reason for hiding this comment

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

A nice change to me, thanks @alamb

@alamb alamb merged commit 18aef7c into apache:main Sep 6, 2023
@alamb alamb deleted the alamb/from_plan_move branch September 7, 2023 16:43
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.

3 participants