Skip to content

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
@alamb alamb requested a review from mustafasrepo December 22, 2023 17:27
///
/// 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
@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

Development

Successfully merging this pull request may close these issues.

Regression: Grouping by an expression with an alias results in Schema error: Schema contains duplicate unqualified field name

2 participants