Grouping sets macro for Redshift

Good evening!

As it is known Redshift does not support ROLLUP, GROUPING SETS and CUBE aggregate functions. Do you know about any macros made by DBT community to programmatically create UNION ALL expressions to mimic GROUPING SETS behaviour?

Thank you.

I had never heard of GROUPING SETS, but I just read up about them here: SQL GROUPING SETS - Generate Multiple Grouping Sets

This is very cool! I would love to support something like it in dbt utils - could you open an issue? Issues · dbt-labs/dbt-utils · GitHub

It’d be sort of like how there is native width_bucket on Snowflake but not others, so we have made an equivalent.

It looks like BQ at least doesn’t support it either: Google BigQuery Grouping Sets Alternative and Example -

1 Like

Thank you for your reply!

I’ve opened the issue: Add `grouping_sets` macro to dbt-utils · Issue #709 · dbt-labs/dbt-utils · GitHub

1 Like