O'Reilly logo

Apache Hive Essentials by Dayong Du

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Set operation – UNION ALL

To operate the result set vertically, Hive only supports UNION ALL right now. And, the result set of UNION ALL keeps duplicates if any. Before Hive 0.13.0, UNION ALL can only be used in the subquery. Since Hive 0.13.0, UNION ALL can also be used in top-level queries. The following are examples of the UNION ALL statements:

  • Check the name column in the employee_hr and employee table:
    jdbc:hive2://> SELECT name FROM employee_hr;
    +----------+
    |   name   |
    +----------+
    | Michael  |
    | Will     |
    | Steven   |
    | Lucy     |
    +----------+
    4 rows selected (0.116 seconds)
    
    jdbc:hive2://> SELECT name FROM employee;
    +----------+
    |   name   |
    +----------+
    | Michael  |
    | Will     |
    | Shelley  |
    | Lucy     |
    +----------+
    4 rows selected (0.049 seconds)
    
  • Use UNION on the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required