Franky's Blog

书山有路勤为径,学海无涯苦作舟……

Hive不支持非等值连接

FAILED: SemanticException [Error 10017]: Line 17:31 Both left and right aliases encountered in JOIN ‘AMOUNT’

原因:Hive不支持非等值连接

现已支持,Complex expressions in ON clause are supported, starting with Hive 2.2.0 (see HIVE-15211, HIVE-15251). Prior to that, Hive did not support join conditions that are not equality conditions.

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Joins

原SQL如下:

 1INSERT INTO TABLE TEST.TMP02_NOT_EQUAL_JOIN
 2SELECT 
 3     B.RULE_NO
 4    ,A.KPI_NO
 5    ,(A.TX_AMT / B.AMOUNT * B.POINT) AS VALUE
 6FROM TEST.TMP01_NOT_EQUAL_JOIN A
 7INNER JOIN TEST.RULE_INFO  B 
 8   ON A.KPI_NO=B.KPI_NO
 9  AND A.TX_AMT >= B.AMOUNT
10;

修改为:

 1INSERT INTO TABLE TEST.TMP02_NOT_EQUAL_JOIN
 2SELECT 
 3     B.RULE_NO    
 4    ,A.KPI_NO
 5    ,(A.TX_AMT / B.AMOUNT * B.POINT) AS VALUE
 6FROM TEST.TMP01_NOT_EQUAL_JOIN A
 7INNER JOIN TEST.RULE_INFO  B 
 8   ON A.KPI_NO=B.KPI_NO
 9WHERE A.TX_AMT >= B.AMOUNT
10;

Share