使用 Impala 的联合查询

Conjuctive queries using Impala

考虑两个表,ratingsproducts,它们有一些列。我正在尝试使用

查询一些数据
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 docs 中没有找到关于此类查询的信息。此查询的正确语法是什么?两者都适用于单独的语句。

Impala 版本为 Impala Shell v1.0 (d1bf0d1) built on Sun Apr 28 15:33:52 PDT 2013。我知道它太旧了,但我不能改变它。

从不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);

您的查询无论如何都会 return 无意义的结果。例如,它将 return 两个表中行数的乘积。