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

Reuse alias if possible #14781

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

blaginin
Copy link
Contributor

@blaginin blaginin commented Feb 19, 2025

Which issue does this PR close?

Rationale for this change

Currently, alias over alias creates an extra expression layer, which gets merged in optimize_projections through an expensive recursive function

What changes are included in this PR?

A small change to reuse an existing alias when possible. This affects two cases:

  • Removes unnecessary info when displaying logical plans
  • Simplifies expressions when optimize_projections isn't called (e.g., when there's only one projection and merge_consecutive_projections isn't run)

Are these changes tested?

Extended doctest

Are there any user-facing changes?

No.

@github-actions github-actions bot added logical-expr Logical plan and expressions sqllogictest SQL Logic Tests (.slt) labels Feb 19, 2025
@alamb
Copy link
Contributor

alamb commented Mar 5, 2025

Interestingly, I was working on a very similar PR last night:

@blaginin
Copy link
Contributor Author

blaginin commented Mar 5, 2025

yes, @alamb, I think we got on the same issue with unnest 😀 - I'm happy to keep working on mine unless you want to take over?

@alamb
Copy link
Contributor

alamb commented Mar 5, 2025

yes, @alamb, I think we got on the same issue with unnest 😀 - I'm happy to keep working on mine unless you want to take over?

Yes, indeed -- something is going on with unnest.

It would be great if you wanted to take over

Feel free to pull over the test case from https://github.com/apache/datafusion/pull/15008/files as well

@alamb alamb mentioned this pull request Mar 5, 2025
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 sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove duplicated alias in Sort
2 participants