考虑两个表,ratings和products,还有一些列。我试图查询一些数据
SELECT AVG(r.rating), COUNT(p.prod_id) FROM ratings as r, products as p;我将其保存为script.impala,并使用impala-shell -f script.impala进行运行。我得到以下信息:
[user@localhost]$ impala-shell -f script.impala *mumble* Query: select AVG(r.rating), COUNT(p.prod_id) FROM ratings as r, products as p ERROR: NotImplementedException: Join between 'r' and 'p' requires at least one conjunctive equality predicate between the two tables Could not execute command: select AVG(r.rating), COUNT(p.prod_id) FROM ratings as r, products as p
我在黑斑羚博士中没有找到关于这类查询的任何信息。这个查询的正确语法是什么?两种方法都能很好地处理单独的陈述。
黑斑羚的版本是Impala Shell v1.0 (d1bf0d1) built on Sun Apr 28 15:33:52 PDT 2013。我知道它太旧了但我不能改变它。
发布于 2017-06-27 13:46:47
不要在FROM子句中使用逗号。始终使用正确、显式的JOIN语法。在您的例子中,您有一个查询。这个怎么样?
select r.avg_rating), p.cnt_products
from (select avg(r.rating) as avg_rating from ratings r) cross join
(select count(*) as cnt_products from products p);不管怎么说,您的查询都会返回无意义的结果。例如,它将返回两个表中行数的乘积。
https://stackoverflow.com/questions/44781729
复制相似问题