Options
- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Solved
Go to solution
ADD TWO TABLES IN HIVE
Labels:
Explorer
Created on ‎07-27-2017 04:59 PM - edited ‎09-16-2022 04:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would like to add the table in a single table if anyone knows kindly let me know, I am getting below errors.
hive> use final; OK Time taken: 0.057 seconds hive> show tables; OK crimeloc13 crimeloc14 crimeloc15 crimeloc16 Time taken: 0.209 seconds hive> select a.loc,a.cnt13 from crimeloc13 a UNION ALL select b.cnt14 from crimeloc14 b; FAILED: SemanticException 1:26 Top level UNION is not supported currently; use a subquery for the UNION. Error encountered near token 'cnt14' hive>
1 ACCEPTED SOLUTION
Super Guru
Created ‎08-02-2017 04:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
As the error message indicated, UNION ALL is not supported at top level, you need to put it in a sub query, similar to below:
SELECT loc, cnt FROM (
select a.loc as loc, a.cnt13 cnt
from crimeloc13 a
UNION ALL
select b.loc as loc, b.cnt14 as cnt
from crimeloc14 b
) a;
As the error message indicated, UNION ALL is not supported at top level, you need to put it in a sub query, similar to below:
SELECT loc, cnt FROM (
select a.loc as loc, a.cnt13 cnt
from crimeloc13 a
UNION ALL
select b.loc as loc, b.cnt14 as cnt
from crimeloc14 b
) a;
1 REPLY 1
Super Guru
Created ‎08-02-2017 04:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
As the error message indicated, UNION ALL is not supported at top level, you need to put it in a sub query, similar to below:
SELECT loc, cnt FROM (
select a.loc as loc, a.cnt13 cnt
from crimeloc13 a
UNION ALL
select b.loc as loc, b.cnt14 as cnt
from crimeloc14 b
) a;
As the error message indicated, UNION ALL is not supported at top level, you need to put it in a sub query, similar to below:
SELECT loc, cnt FROM (
select a.loc as loc, a.cnt13 cnt
from crimeloc13 a
UNION ALL
select b.loc as loc, b.cnt14 as cnt
from crimeloc14 b
) a;
