[ 
https://issues.apache.org/jira/browse/HIVE-26493?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

László Végh updated HIVE-26493:
-------------------------------
    Description: 
Steps to reproduce:
 # Create table tbl_x

{noformat}
create table tbl_x (a int, b string); {noformat}

 # Insert data in the table

{noformat}
insert into tbl_x values (1, 'Prince'); insert into tbl_x values (2, 'John'); 
{noformat}

 # view data in table :

{noformat}
select * from tbl_x;
+----------+----------+ 
|tbl_x.a   |tbl_x.b   | 
+----------+----------+ 
|1         |Prince    | 
|2         | John     |{noformat}

 # Create view:

{noformat}
create view vw_x (b) as (select a from tbl_x);{noformat}

 # Try to read data from view:

{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

{noformat}
drop view vw_x; {noformat}

 # Create the view again with the below definition:

{noformat}
create view vw_x (b) as select a from tbl_x; {noformat}

 # Try to read the data from view:

{noformat}
select * from vw_x;
+---------+ 
| vw_x.b  | 
+---------+ 
| 1       | 
| 2       | 
+---------+ {noformat}

  was:
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}


> 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
>            Priority: Major
>
> Steps to reproduce:
>  # Create table tbl_x
> {noformat}
> create table tbl_x (a int, b string); {noformat}
>  # Insert data in the table
> {noformat}
> insert into tbl_x values (1, 'Prince'); insert into tbl_x values (2, 'John'); 
> {noformat}
>  # view data in table :
> {noformat}
> select * from tbl_x;
> +----------+----------+ 
> |tbl_x.a   |tbl_x.b   | 
> +----------+----------+ 
> |1         |Prince    | 
> |2         | John     |{noformat}
>  # Create view:
> {noformat}
> create view vw_x (b) as (select a from tbl_x);{noformat}
>  # Try to read data from view:
> {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
> {noformat}
> drop view vw_x; {noformat}
>  # Create the view again with the below definition:
> {noformat}
> create view vw_x (b) as select a from tbl_x; {noformat}
>  # Try to read the data from view:
> {noformat}
> select * from vw_x;
> +---------+ 
> | vw_x.b  | 
> +---------+ 
> | 1       | 
> | 2       | 
> +---------+ {noformat}



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

Reply via email to