ParseException - 子查询源中的输入不匹配 - Hive中的错误

时间:2014-07-31 12:51:04

标签: sql hadoop hive

我在Hive中运行下一个查询:

SELECT COUNT(*) 
FROM 
  (
   SELECT * 
   FROM 
   (SELECT id, COUNT(*) AS count_p_id FROM palladion GROUP BY id) a, 
   (SELECT cid, COUNT(*) AS count_q_cid FROM operations GROUP BY cid) b 
   WHERE a.id=b.cid
  ) 
WHERE count_p_id < count_q_cid;

我一直收到像

这样的错误
 ParseException line 1:103 mismatched input ',' expecting ) near 'a' in subquery source

代码有什么问题?我看不到任何。

1 个答案:

答案 0 :(得分:1)

从Hive 0.13.0开始支持隐式连接表示法。这允许FROM子句加入以逗号分隔的表列表,省略JOIN关键字。例如:

SELECT *
FROM table1 t1, table2 t2
WHERE t1.id = t2.id

我希望你正在使用&lt; 0.13.0版本。如果你的hive版本是&lt; 0.13.0

试试这个:你必须使用JOIN - ON,而不是逗号 - WHERE

SELECT COUNT(*) 
FROM 
  (
   SELECT * 
   FROM 
   (SELECT id, COUNT(*) AS count_p_id FROM palladion GROUP BY id) a JOIN 
   (SELECT cid, COUNT(*) AS count_q_cid FROM operations GROUP BY cid) b 
   ON  a.id=b.cid
  ) 
WHERE count_p_id < count_q_cid;