-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Unable to use calculated column in grouping sets #8646
Comments
Facing the same issue. The only workaround is to calculate the derived column using a join with a lookup table which maps the original column to derived column and then do grouping set on the derived column. Since it work in GROUP BY, it should work in GROUPING SETS also. Syntactically the best would be if we could use the alias from select statement in group by and grouping sets. |
It's not clear what that would mean, since the expressions in the SELECT clause are "evaluated" on the results of the aggregation (group by/grouping sets) phase. |
You also can't use column index in grouping sets. These are successful: These fail: All of these failed cases work intuitively in Vertica SQL, some details here: https://www.vertica.com/docs/9.2.x/HTML/Content/Authoring/SQLReferenceManual/Statements/SELECT/GROUPBYClause.htm?zoom_highlight=grouping%20sets Choosing some/all of these to support would be great. |
This issue has been automatically marked as stale because it has not had any activity in the last 2 years. If you feel that this issue is important, just comment and the stale tag will be removed; otherwise it will be closed in 7 days. This is an attempt to ensure that our open issues remain valuable and relevant so that we can keep track of what needs to be done and prioritize the right things. |
Just wanted to add that I am missing this functionality a lot as well. Grouping sets are incredibly useful, but being able to use either number references for column or use the name of a derived column would be absolutely great! |
When trying to use calculated column in grouping set error showing that query is not valid is thrown.
examples:
select transaction_id, term_start, 'test' as test, sum(quantity) from transaction group by grouping sets ((transaction_id, 'test'), (transaction_id, term_start));
throws
at the same time it is not possible to use calculated column alias (expected).
This works when using just group by without grouping sets.
The text was updated successfully, but these errors were encountered: