Anant Mittal created HIVE-18914:
-----------------------------------

             Summary: View definition resolved incorrectly for windowing case
                 Key: HIVE-18914
                 URL: https://issues.apache.org/jira/browse/HIVE-18914
             Project: Hive
          Issue Type: Bug
            Reporter: Anant Mittal


Select from a view leads to error as column name is not resolved properly.

Error seen:

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: Line 1:182 
Expression not in GROUP BY key 'amt' in definition of VIEW badview [
select `t1`.`partcol` from (select `b`.`partcol`, `b`.`amt`, `b`.`rownum` from 
( SELECT  partCol, +*SUM(`tdr`.`amt`)*+ AS `amt`, row_number() over (partition 
by `tdr`.`partcol` order by sum(+*amt*+) desc) `rownum` FROM (select 
`source`.`partcol`,`source`.`amt` from `default`.`source` group by 
`source`.`partcol`,`source`.`amt` )as `tdr` group by `tdr`.`partcol`)as `b`)as 
`t1` group by `t1`.`partcol`
] used as badview at Line 1:14

 

Queries to reproduce:

CREATE TABLE source(partCol STRING,amt DECIMAL(38,3));

CREATE VIEW badView AS select partCol from (select b.* from ( SELECT  partCol, 
SUM(amt) AS amt, row_number() over (partition by partCol order by sum(amt) 
desc) rownum FROM (select partCol,amt from source group by partCol,amt )as tdr 
group by partCol)as b)as t1 group by partCol;

select * from badView;

 

Note: Running the subquery in the AS part of view definition works correctly.

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to