[ 
https://issues.apache.org/jira/browse/HIVE-10698?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14544177#comment-14544177
 ] 

Pengcheng Xiong commented on HIVE-10698:
----------------------------------------

According to [~jpullokkaran]'s comments, add the following things to do

1. When a fully qualified identifier (db.tablename) is specified in the from 
clause we seems to resolve it against CTE aliases. This is wrong if table 
doesn't exist in catalog then we should fail.
2. If fully qualified name is not used in the from clause then 
a) we should first resolve the identifier against CTE aliases 
b) if identifier is not found in the CTE list then try to resolve against 
catalog.
3) Views: in unparsetranslator we treat CTE name as catalog table; this is a 
bug.

> query on view results fails with table not found error if view is created 
> with subquery alias (CTE).
> ----------------------------------------------------------------------------------------------------
>
>                 Key: HIVE-10698
>                 URL: https://issues.apache.org/jira/browse/HIVE-10698
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Pengcheng Xiong
>            Assignee: Pengcheng Xiong
>
> To reproduce it, 
> {code}
> use bugtest;
> create table basetb(id int, name string);
> create view testv1 as
> with subtb as (select id, name from bugtest.basetb)
> select id from subtb;
> use castest;
> explain select * from bugtest.testv1;
> hive> explain select * from bugtest.testv1;
> FAILED: SemanticException Line 2:15 Table not found 'subtb' in definition of 
> VIEW testv1 [
> with subtb as (select id, name from bugtest.basetb)
> select id from `bugtest`.`subtb`
> ] used as testv1 at Line 1:22
> Note that there is a database prefix `bugtest`.`subtb`
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to