-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
UNION ALL sets the wrong column alias if union arm has aggregate expression #6139
Comments
Working on it |
@alamb @jackwener may I ask your help? I have found why projection is not correct. push_down_projection for union never called for query like that
However its called for
The reason for that UNION has another logical plan
UNION ALL
UNION have a weird top Aggregate node, which looks strange for me. as Aggregation happens twice in that case, but because of that UNION push_down_projection works. I'm trying to understand the real rootcause if it in bad plan generated in the first place or bug in push_down_projection UPD: Excessive aggregation for UNION is likely distinct values |
the effect of that is another bug with simple union all table creation(without aggr)
|
|
Thanks, I was expecting DISTINCT in plan, not a aggregation. But DISTINCT may be can considered as partial case of aggregation |
I agree that Distinct would be clearer in the LogicalPlan (though it gets rewritten to Aggregate pretty early on as I recall). Maybe it would be clearer to remove |
Yes, it's replaced in rule |
Describe the bug
UNION ALL sets the wrong column alias if first union arm has aggregate expression, see query below.
To Reproduce
Without group by the query works fine
select count(1) x from (select 1 a) a union all select 1 b;
Expected behavior
The test should pass
Additional context
Related to #5695 #5747
The text was updated successfully, but these errors were encountered: