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.
Using CUBE and ROLLUP - Hive Tutorial
From the course: Analyzing Big Data with Hive
Using CUBE and ROLLUP
- [Instructor] Now with Hive, there's some additional ways to perform these aggregations, using CUBE an ROLLUP. These are almost like shortcuts, and the first one, CUBE, returns all possible aggregation combinations, and the second one, ROLLUP, does it, but in a more hierarchical fashion. Let's take a look, and we're going to replace grouping sets with CUBE, and then similarly, replace grouping sets with ROLLUP. Okay, so back here in my Cloud Air environment, I'm going to open up 4-3.sql. And I'm going to copy everything out of here, and go back over to my hue editor. And on top let's take a look, with using CUBE. So it essentially returns subtotals of all possible combinations. That can be dangerous if you have a large data set, so be very careful about it. Now if you're not sure which aggregation level you want, you can use with CUBE at the end of your query, of an aggregate query that has a group by, and it will automatically return all of them, but be careful because it is going…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.