Hive 为什么获取失败:无效的表别名或列引用‘’;:(可能的列名是:line)当我在配置单元中查询时?

Hive 为什么获取失败:无效的表别名或列引用‘’;:(可能的列名是:line)当我在配置单元中查询时?,hive,hiveql,Hive,Hiveql,我有一个表,其结构是: line string 内容是: product_id product_date orderattribute1 orderattribute2 orderattribute3 orderattribute4 ciiquantity ordquantity price 1 2014-09 2 1 1 1 1 3 153 1 2014-01 2 1 1 1 1 1 153 1 2014-04 2 2 1 1 1 1 164 1 2014-02 2 1 1

我有一个表,其结构是:

line      string
内容是:

product_id product_date orderattribute1 orderattribute2 orderattribute3     orderattribute4 ciiquantity ordquantity price
1 2014-09 2 1 1 1 1 3 153
1 2014-01 2 1 1 1 1 1 153
1 2014-04 2 2 1 1 1 1 164
1 2014-02 2 1 1 1 3 4 162
1 2014-07 2 1 1 1 9 23 224
1 2014-08 2 1 1 1 1 7 216
1 2014-03 2 1 1 1 3 13 180
1 2014-08 2 2 1 1 4 6 171
1 2014-05 2 1 1 1 3 7 180
....
(19000 lines omited)
以上每一行的总价格为订单数量*价格

我想得到每个
月的总价格,如下所示:

month   sum
201401  ****
201402  ****
根据上表中的10行,201408个月的总和为7*216+6*171,其来源于(2014-08年1.11.17 216和2014-08年1.21.7 216)

我使用代码:

create table product as select sum(ordquantity*price) as sum from text3 group by product_date;
我得到了失败的答案:

FAILED:Invalid table alias or column reference 'product_date': (possible column names are: line) 

我不熟悉Hive,我不知道如何解决这个问题。

您刚才是否使用正确的模式创建了表?以防万一,如果你没有

CREATE TABLE product
(product_id INT 
product_date STRING
orderattribute1 INT
orderattribute2 INT
orderattribute3 INT
orderattribute4 INT
ciiquantity INT
ordquantity INT
price INT)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n';
还有你要求的代码

SELECT product_date, SUM(ordquantity*price) FROM product
GROUP BY product_date;

希望我回答了你的问题。哎呀

谢谢你详细的回答!