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

Fix group by aliased expression in LogicalPLanBuilder::aggregate #8629

Merged
merged 1 commit into from
Dec 26, 2023

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Dec 22, 2023

Which issue does this PR close?

Closes #8628

Rationale for this change

Fixed regression introduced in #8356 as explained on #8628

What changes are included in this PR?

  1. Fix bug by not adding synthetic columns with duplicated namess
  2. Improve comments
  3. Add test

Are these changes tested?

Yes

Are there any user-facing changes?

Fix bug

@github-actions github-actions bot added logical-expr Logical plan and expressions core Core DataFusion crate labels Dec 22, 2023
///
/// This allows MySQL style selects like
/// `SELECT col FROM t WHERE pk = 5` if col is unique
fn add_group_by_exprs_from_dependencies(
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 pulled the logic into its own function so I could document it better

let expr =
Expr::Column(Column::new(field.qualifier().cloned(), field.name()));
let expr_name = expr.display_name()?;
if !group_by_field_names.contains(&expr_name) {
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 is the change -- rather than comparing the Exprs it compares their display_name (the fields they will create)

Copy link
Contributor

@mustafasrepo mustafasrepo left a comment

Choose a reason for hiding this comment

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

Thanks @alamb LGTM!

@alamb
Copy link
Contributor Author

alamb commented Dec 26, 2023

Thank you for the review @mustafasrepo

@alamb alamb merged commit 26a8000 into apache:main Dec 26, 2023
22 checks passed
@alamb alamb deleted the alamb/fix_deps branch December 26, 2023 12:04
appletreeisyellow pushed a commit to appletreeisyellow/datafusion that referenced this pull request Jan 1, 2024
appletreeisyellow pushed a commit to appletreeisyellow/datafusion that referenced this pull request Jan 2, 2024
appletreeisyellow pushed a commit to appletreeisyellow/datafusion that referenced this pull request Jan 2, 2024
appletreeisyellow pushed a commit to appletreeisyellow/datafusion that referenced this pull request Jan 3, 2024
appletreeisyellow pushed a commit to appletreeisyellow/datafusion that referenced this pull request Jan 3, 2024
appletreeisyellow pushed a commit to appletreeisyellow/datafusion that referenced this pull request Jan 4, 2024
appletreeisyellow pushed a commit to appletreeisyellow/datafusion that referenced this pull request Jan 4, 2024
appletreeisyellow pushed a commit to appletreeisyellow/datafusion that referenced this pull request Jan 4, 2024
appletreeisyellow pushed a commit to appletreeisyellow/datafusion that referenced this pull request Jan 4, 2024
appletreeisyellow pushed a commit to appletreeisyellow/datafusion that referenced this pull request Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate logical-expr Logical plan and expressions
Projects
None yet
2 participants