Skip to content

fix(expr): Rename aliases in set expression to the left side schema field to avoid duplicate field name errors - #27473

Merged
AdamGS merged 1 commit into
apache:mainfrom
AdamGS:adamg/set-expr-duplicate-aliases
Nov 16, 2026
Merged

AdamGS merged 1 commit into
apache:mainfrom
AdamGS:adamg/set-expr-duplicate-aliases

Conversation

@AdamGS

@AdamGS AdamGS commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Ran into this issue while working on #27380, and the motivating case here is aliases like count(1) AS "count(*), which is even mentioned in the call site in datafusion/sql/src/select.rs. I've also found the already existing issue mentioned above.

What changes are included in this PR?

Instead of keeping aliases as they are, we also rename them to the left side's schema field name.

What is the testing strategy for this PR?

Added dedicated SLT cases, which I've also verified against DuckDB.

Are there any user-facing changes?

Should only enable new cases.

@AdamGS
AdamGS force-pushed the adamg/set-expr-duplicate-aliases branch from 8849c70 to 5663378 Compare November 16, 2026 12:52
@github-actions github-actions Bot added logical-expr Logical plan and expressions sqllogictest SQL Logic Tests (.slt) labels Nov 16, 2026

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you -- makes sense to me @AdamGS

@AdamGS
AdamGS added this pull request to the merge queue Nov 16, 2026
Merged via the queue into apache:main with commit e2dc8b0 Nov 16, 2026
42 checks passed
@AdamGS
AdamGS deleted the adamg/set-expr-duplicate-aliases branch November 16, 2026 17:13
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) v57.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

the select clause after union all has many same name columns needn't use different aliases

2 participants