From the course: Analyzing Big Data with Hive

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Enhanced aggregations with grouping sets

Enhanced aggregations with grouping sets - Hive Tutorial

From the course: Analyzing Big Data with Hive

Start my 1-month free trial

Enhanced aggregations with grouping sets

- [Instructor] Here we're going to take a look at enhanced aggregations with grouping sets, which sounds confusing, so let's break it down first. Grouping sets is a way that you can ask Hive to return multiple levels of aggregation in just one SELECT statement. That's how the GROUPING SETS works, you pass in a set of things to do GROUP BY functions on, and it will return all the different levels of aggregation. Looking at it here, if we had a very basic query with SELECT a and b and sum of c, so we're adding up all the values in c, from MyTable, group by a and b, and then we return GROUPING SETS, so this is an additional clause that we can add to provide additional levels of aggregation. What this would bring back is it would bring back the combination of a and b, so the typical thing that we would see where we would have the sum of c at a and b intersections, then, because in our grouping set we have comma a individually and then comma b individually, we would also receive those…

Contents