hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aihu...@apache.org
Subject hive git commit: HIVE-15231: query on view with CTE and alias fails with table not found error (Aihua Xu, reviewed by Pengcheng Xiong, Xuefu Zhang)
Date Fri, 18 Nov 2016 14:08:57 GMT
Repository: hive
Updated Branches:
  refs/heads/master 936df7a15 -> cea954f5c


HIVE-15231: query on view with CTE and alias fails with table not found error (Aihua Xu, reviewed
by Pengcheng Xiong, Xuefu Zhang)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/cea954f5
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/cea954f5
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/cea954f5

Branch: refs/heads/master
Commit: cea954f5c93bc8830c9358ad16d3c39aaf9c9de8
Parents: 936df7a
Author: Aihua Xu <aihuaxu@apache.org>
Authored: Thu Nov 17 16:15:47 2016 -0500
Committer: Aihua Xu <aihuaxu@apache.org>
Committed: Fri Nov 18 09:08:09 2016 -0500

----------------------------------------------------------------------
 .../hadoop/hive/ql/parse/SemanticAnalyzer.java  |  4 +-
 ql/src/test/queries/clientpositive/cteViews.q   |  8 ++++
 .../test/results/clientpositive/cteViews.q.out  | 46 ++++++++++++++++++++
 3 files changed, 56 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/cea954f5/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
index 8f5542b..47feeaf 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
@@ -825,9 +825,9 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
 
     qb.getParseInfo().setSrcForAlias(alias, tableTree);
 
-    // if alias to CTE contains the alias, we do not do the translation because
+    // if alias to CTE contains the table name, we do not do the translation because
     // cte is actually a subquery.
-    if (!this.aliasToCTEs.containsKey(alias)) {
+    if (!this.aliasToCTEs.containsKey(tabIdName)) {
       unparseTranslator.addTableNameTranslation(tableTree, SessionState.get().getCurrentDatabase());
       if (aliasIndex != 0) {
         unparseTranslator.addIdentifierTranslation((ASTNode) tabref.getChild(aliasIndex));

http://git-wip-us.apache.org/repos/asf/hive/blob/cea954f5/ql/src/test/queries/clientpositive/cteViews.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/cteViews.q b/ql/src/test/queries/clientpositive/cteViews.q
index c076841..4567b47 100644
--- a/ql/src/test/queries/clientpositive/cteViews.q
+++ b/ql/src/test/queries/clientpositive/cteViews.q
@@ -38,4 +38,12 @@ use bug;
 select * from default.v;
 use default;
 drop view v;
+
+create view v as with src1 as (select key from src order by key limit 5)
+select * from src1 a where a.key is not null;
+
+describe extended v;
+select * from v;
+drop view v;
+
 drop database bug;

http://git-wip-us.apache.org/repos/asf/hive/blob/cea954f5/ql/src/test/results/clientpositive/cteViews.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/cteViews.q.out b/ql/src/test/results/clientpositive/cteViews.q.out
index 6291784..eb3cfc0 100644
--- a/ql/src/test/results/clientpositive/cteViews.q.out
+++ b/ql/src/test/results/clientpositive/cteViews.q.out
@@ -232,6 +232,52 @@ POSTHOOK: query: drop view v
 POSTHOOK: type: DROPVIEW
 POSTHOOK: Input: default@v
 POSTHOOK: Output: default@v
+PREHOOK: query: create view v as with src1 as (select key from src order by key limit 5)
+select * from src1 a where a.key is not null
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@src
+PREHOOK: Output: database:default
+PREHOOK: Output: default@v
+POSTHOOK: query: create view v as with src1 as (select key from src order by key limit 5)
+select * from src1 a where a.key is not null
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@src
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@v
+PREHOOK: query: describe extended v
+PREHOOK: type: DESCTABLE
+PREHOOK: Input: default@v
+POSTHOOK: query: describe extended v
+POSTHOOK: type: DESCTABLE
+POSTHOOK: Input: default@v
+key                 	string              	                    
+	 	 
+#### A masked pattern was here ####
+select * from src1 a where a.key is not null, viewExpandedText:with src1 as (select `src`.`key`
from `default`.`src` order by key limit 5)	 	 
+select `a`.`key` from src1 a where `a`.`key` is not null, tableType:VIRTUAL_VIEW)		 
+PREHOOK: query: select * from v
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Input: default@v
+#### A masked pattern was here ####
+POSTHOOK: query: select * from v
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Input: default@v
+#### A masked pattern was here ####
+0
+0
+0
+10
+100
+PREHOOK: query: drop view v
+PREHOOK: type: DROPVIEW
+PREHOOK: Input: default@v
+PREHOOK: Output: default@v
+POSTHOOK: query: drop view v
+POSTHOOK: type: DROPVIEW
+POSTHOOK: Input: default@v
+POSTHOOK: Output: default@v
 PREHOOK: query: drop database bug
 PREHOOK: type: DROPDATABASE
 PREHOOK: Input: database:bug


Mime
View raw message