Quantcast
Channel: 蜗牛都知道
Viewing all articles
Browse latest Browse all 105

Hive UNION ALL报错Top level UNION is not supported currently

$
0
0

来源:四号程序员

下面只是一个例子,一般用OR 条件肯定会搞定的。

SELECT a, b from tb1 where a > 100
UNION
SELECT a, b from tb2 where a > 1000;

会报错 FAILED: SemanticException 1:62 Top level UNION is not supported currently; use a subquery for the UNION. Error encountered near token ‘””‘

正确的做法是:把所有UNION ALL子句放到sub-query中,并且给table加别名,如下:

SELECT * FROM
(
SELECT a, b from tb1 where a > 100
UNION
SELECT a, b from tb2 where a > 1000
) tmp;

Viewing all articles
Browse latest Browse all 105

Trending Articles