Hive - 在多个表/子查询中找到列

时间:2016-12-24 12:10:41

标签: hadoop hive subquery

我需要在Hive中创建一个包含多个子查询的表。查询是:

CREATE TABLE table AS
select dense_rank() OVER (ORDER BY Client) AS Client,
       A.STORE,
       from_unixtime(unix_timestamp(A.DATE_Client , 'yyyy-MM-dd')) AS Date_Client,
      year(A.DATE_Client) as YEAR_Client,
       (INT((MONTH(A.DATE_Client)-1)/3)+1) as QUARTER_Client,
       MONTH(A.DATE_Client) as MONTH_Client,
       weekofyear(A.DATE_Client) as WEEK_Client,
       DAY(A.DATE_Client) as DAY_Client,
       from_unixtime(unix_timestamp(A.DATE_Client , 'yyyy-MM-dd'),'u') as WeekDay,
       b.Last_Visit,
       A.transaction_value/A.transaction_Quantity AS PRODUCT_VALUE
from (select e.*,
            tb1.seqnum
      from (SELECT Distinct d.STORE as STORE_rank,DENSE_RANK() over (order by d.STORE, RAND()) as seqnum from staging_area d) tb1
      join staging_area e
      on tb1.STORE_rank = e.STORE
     ) A
JOIN (SELECT Client, MAX(DATE_Client) AS Last_Visit
            FROM LAST_VISIT
            GROUP BY Client) B
ON A.Client = B.Client
where seqnum < 41 and Date_Client >= '2013-01-01' and Date_Client <= '2013-30';

但是,当我尝试运行此操作时,我收到以下错误:

Error while compiling statement: FAILED: SemanticException Failed to breakup Windowing invocations into Groups. At least 1 group must only depend on input columns. Also check for circular dependencies. Underlying error: org.apache.hadoop.hive.ql.parse.SemanticException: Column client Found in more than One Tables/Subqueries

任何人都知道如何解决这个问题?

非常感谢!

0 个答案:

没有答案