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

Andre Araujo updated HIVE-21745:
--------------------------------
    Description: 
I ran into the following case, where a query fails to parse if the join order 
is changed:

{code}
create database if not exists test;

drop table if exists test.table1;
create table test.table1 (
  id string,
  col_a string
)
stored as textfile;

drop table if exists test.table2;
create table test.table2 (
  id string
)
stored as textfile;

drop table if exists test.table3;
create table test.table3 (
  col_a string,
  col_b string
)
stored as textfile;

drop table if exists test.table4;
create table test.table4 (
  id string
)
stored as textfile;

-- This fails with: Invalid table alias or column reference 't3': (possible 
column names are: id, col_a)
drop view if exists test.v;
create view test.v as
select
  1
from
  test.table1 as t1
  left join test.table2 as t2 on t2.id = t1.id
  left join test.table3 as t3 on t1.col_a = t3.col_a
  left join test.table4 as t4 on t1.id = t4.id and t3.col_b = 'X'
;

-- This works
drop view if exists test.v;
create view test.v as
select
  1
from
  test.table1 as t1
  left join test.table3 as t3 on t1.col_a = t3.col_a
  left join test.table4 as t4 on t1.id = t4.id and t3.col_b = 'X'
  left join test.table2 as t2 on t2.id = t1.id
;
{code}

  was:
I ran into the following case, where a query fails to parse if the join order 
is changed:

{code}
reate database if not exists test;

drop table if exists test.table1;
create table test.table1 (
  id string,
  col_a string
)
stored as textfile;

drop table if exists test.table2;
create table test.table2 (
  id string
)
stored as textfile;

drop table if exists test.table3;
create table test.table3 (
  col_a string,
  col_b string
)
stored as textfile;

drop table if exists test.table4;
create table test.table4 (
  id string
)
stored as textfile;

-- This fails with: Invalid table alias or column reference 't3': (possible 
column names are: id, col_a)
drop view if exists test.v;
create view test.v as
select
  1
from
  test.table1 as t1
  left join test.table2 as t2 on t2.id = t1.id
  left join test.table3 as t3 on t1.col_a = t3.col_a
  left join test.table4 as t4 on t1.id = t4.id and t3.col_b = 'X'
;

-- This works
drop view if exists test.v;
create view test.v as
select
  1
from
  test.table1 as t1
  left join test.table3 as t3 on t1.col_a = t3.col_a
  left join test.table4 as t4 on t1.id = t4.id and t3.col_b = 'X'
  left join test.table2 as t2 on t2.id = t1.id
;
{code}


> Change in join order causes query parse to fail
> -----------------------------------------------
>
>                 Key: HIVE-21745
>                 URL: https://issues.apache.org/jira/browse/HIVE-21745
>             Project: Hive
>          Issue Type: Bug
>          Components: Hive
>    Affects Versions: 1.1.0
>            Reporter: Andre Araujo
>            Priority: Major
>
> I ran into the following case, where a query fails to parse if the join order 
> is changed:
> {code}
> create database if not exists test;
> drop table if exists test.table1;
> create table test.table1 (
>   id string,
>   col_a string
> )
> stored as textfile;
> drop table if exists test.table2;
> create table test.table2 (
>   id string
> )
> stored as textfile;
> drop table if exists test.table3;
> create table test.table3 (
>   col_a string,
>   col_b string
> )
> stored as textfile;
> drop table if exists test.table4;
> create table test.table4 (
>   id string
> )
> stored as textfile;
> -- This fails with: Invalid table alias or column reference 't3': (possible 
> column names are: id, col_a)
> drop view if exists test.v;
> create view test.v as
> select
>   1
> from
>   test.table1 as t1
>   left join test.table2 as t2 on t2.id = t1.id
>   left join test.table3 as t3 on t1.col_a = t3.col_a
>   left join test.table4 as t4 on t1.id = t4.id and t3.col_b = 'X'
> ;
> -- This works
> drop view if exists test.v;
> create view test.v as
> select
>   1
> from
>   test.table1 as t1
>   left join test.table3 as t3 on t1.col_a = t3.col_a
>   left join test.table4 as t4 on t1.id = t4.id and t3.col_b = 'X'
>   left join test.table2 as t2 on t2.id = t1.id
> ;
> {code}



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

Reply via email to