László Végh created HIVE-26493:
----------------------------------

             Summary: Hive throws error when querying a view that was created 
successfully
                 Key: HIVE-26493
                 URL: https://issues.apache.org/jira/browse/HIVE-26493
             Project: Hive
          Issue Type: Bug
            Reporter: László Végh


Steps to reproduce:
 # Create table tbl_x 

{code:java}
create table tbl_x (a int, b string); {code}

 # Insert data in the table 

{code:java}
insert into tbl_x values (1, 'Prince'); insert into tbl_x values (2, 'John'); 
{code}

 # view data in table : 

{code:java}
select * from tbl_x  {code}


{noformat}
+----------+----------+ 
|tbl_x.a   |tbl_x.b   | 
+----------+----------+ 
|1         |Prince    |
|2         | John     |{noformat}

 # Create view: 

{code:java}
create view vw_x (b) as (select a from tbl_x);{code}

 # Triy to read data from view but: 

{noformat}
Error while compiling statement: FAILED: SemanticException line 1:67 cannot 
recognize input near ')' 'vw_x' '<EOF>' in subquery source in definition of V 
IEW vw_x [ SELECT `a` AS `b` FROM ((select `tbl_x`.`a` from `default`.`tbl_x`)) 
`vw_x` ] used as vw_x at Line 1:14 (state=42000,code=40000) {noformat}

 # Drop the view 

{code:java}
drop view vw_x; {code}

 # Created the view again with the below definition: 

{code:java}
create view vw_x (b) as select a from tbl_x; {code}

 # Tried to read the data from view: 
select * from vw_x; 

{noformat}
+---------+
| vw_x.b  | 
+---------+
| 1       | 
| 2       | 
+---------+ {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to