在配置单元查询中使用四级嵌套时,我遇到了一个问题。下面是我正在执行的查询-
SELECT *,
SUM(qtod.amount) OVER (PARTITION BY qtod.id, qtod.year_begin_date ORDER BY qtod.tran_date)
FROM (SELECT *,
SUM(mtod.amount) OVER (PARTITION BY mtod.id, mtod.quarter_begin_date ORDER BY mtod.tran_date)
FROM (SELECT *,
SUM(wtod.amount) OVER (PARTITION BY wtod.id, wtod.month_begin_date ORDER BY wtod.tran_date)
FROM (select id,
year_begin_date,
quarter_begin_date,
month_begin_date,
week_begin_date,
tran_date,
amount,
SUM(amount)
OVER (PARTITION BY id,week_begin_date ORDER BY tran_date) FROM table_name)wtod)mtod)qtod;
如果我排除第四级嵌套,它工作得很好,但在包含它的同时,会低于error msg-
失败:semanticexception[错误10007]:qtod中的列引用不明确\u c1
为了避免筑巢,我尝试了另一种方法
SELECT * FROM
(SELECT id,year_begin_date,tran_date,amount,SUM(amount) OVER (PARTITION BY id,year_begin_date ORDER BY tran_date) FROM yeartodate)ytod
JOIN
(SELECT *, SUM(mtod.amount) OVER (PARTITION BY mtod.id, mtod.quarter_begin_date ORDER BY mtod.tran_date)
FROM (SELECT *, SUM(wtod.amount) OVER (PARTITION BY wtod.id, wtod.month_begin_date ORDER BY wtod.tran_date)
FROM (select id,
year_begin_date,
quarter_begin_date,
month_begin_date,
week_begin_date,
tran_date,
amount,
SUM(amount)
OVER (PARTITION BY id,week_begin_date ORDER BY tran_date) FROM table_name)wtod)mtod)qtod
ON qtod.id=ytod.id AND qtod.tran_date=ytod.tran_date;
还是有同样的错误。
在网上搜索后,我发现这是一个与Hive本身的问题,根据吉拉提出的Hive
由于jira现在已经修复,并且补丁程序在hive14中可用,所以我尝试在hive14(hdp)上运行它。
还是有同样的错误。
请写下你的建议。。。。。
1条答案
按热度按时间w46czmvw1#
函数中的非别名函数调用
SELECT
Map到列名_c1
,_c2
在这种情况下,每个SELECT
,所以它们都创建一个列_c1
.问题是因为你在做
SELECT *
从下一个子查询向下,然后附加另一个Map到_c1
然后,同一列被命名了两次,因此在不明确的列引用周围出现了一个错误。解决方案应该是对所有函数调用使用别名,这样它们就不会使用
_c1
默认名称,如下所示: