hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject [17/44] hive git commit: HIVE-14805: Subquery inside a view will have the object in the subquery as the direct input (Aihua Xu, reviewed by Yongzhi Chen)
Date Sat, 01 Oct 2016 01:08:59 GMT
HIVE-14805: Subquery inside a view will have the object in the subquery as the direct input
(Aihua Xu, reviewed by Yongzhi Chen)


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

Branch: refs/heads/hive-14535
Commit: f284b6d04aea51bce4e438f31a7b5ed8597df8fd
Parents: da376eb
Author: Aihua Xu <aihuaxu@apache.org>
Authored: Wed Sep 21 13:59:14 2016 -0400
Committer: Aihua Xu <aihuaxu@apache.org>
Committed: Fri Sep 23 09:07:15 2016 -0400

----------------------------------------------------------------------
 .../hadoop/hive/ql/parse/SemanticAnalyzer.java  |  2 +-
 .../hadoop/hive/ql/plan/TestViewEntity.java     | 31 +++++++++++
 .../results/clientpositive/cbo_union_view.q.out | 12 +++++
 .../results/clientpositive/ppd_union_view.q.out | 12 +++++
 .../results/clientpositive/union_view.q.out     | 54 ++++++++++++++++++++
 5 files changed, 110 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/f284b6d0/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 577d006..747f387 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
@@ -997,7 +997,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
     // Recursively do the first phase of semantic analysis for the subquery
     QBExpr qbexpr = new QBExpr(alias);
 
-    doPhase1QBExpr(subqref, qbexpr, qb.getId(), alias);
+    doPhase1QBExpr(subqref, qbexpr, qb.getId(), alias, qb.isInsideView());
 
     // If the alias is already there then we have a conflict
     if (qb.exists(alias)) {

http://git-wip-us.apache.org/repos/asf/hive/blob/f284b6d0/ql/src/test/org/apache/hadoop/hive/ql/plan/TestViewEntity.java
----------------------------------------------------------------------
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/plan/TestViewEntity.java b/ql/src/test/org/apache/hadoop/hive/ql/plan/TestViewEntity.java
index 2d70a1b..fa01416 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/plan/TestViewEntity.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/plan/TestViewEntity.java
@@ -141,4 +141,35 @@ public class TestViewEntity {
 
   }
 
+  /**
+   * Verify that the the query with the subquery inside a view will have the correct
+   * direct and indirect inputs.
+   * @throws Exception
+   */
+  @Test
+  public void testSubQueryInSubView() throws Exception {
+    String prefix = "tvsubqueryinsubview" + NAME_PREFIX;
+    final String tab1 = prefix + "t";
+    final String view1 = prefix + "v";
+    final String view2 = prefix + "v2";
+
+    int ret = driver.run("create table " + tab1 + "(id int)").getResponseCode();
+    assertEquals("Checking command success", 0, ret);
+    ret = driver.run("create view " + view1 + " as select * from " + tab1).getResponseCode();
+    assertEquals("Checking command success", 0, ret);
+
+    ret = driver.run("create view " + view2 + " as select * from (select * from " + view1
+ ") x").getResponseCode();
+    assertEquals("Checking command success", 0, ret);
+
+    driver.compile("select * from " + view2);
+    // view entity
+    assertEquals("default@" + view2, CheckInputReadEntity.readEntities[0].getName());
+
+    // table1 and view1 as second read entity
+    assertEquals("default@" + view1, CheckInputReadEntity.readEntities[1].getName());
+    assertFalse("Table is not direct input", CheckInputReadEntity.readEntities[1].isDirect());
+    assertEquals("default@" + tab1, CheckInputReadEntity.readEntities[2].getName());
+    assertFalse("Table is not direct input", CheckInputReadEntity.readEntities[2].isDirect());
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/f284b6d0/ql/src/test/results/clientpositive/cbo_union_view.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/cbo_union_view.q.out b/ql/src/test/results/clientpositive/cbo_union_view.q.out
index ed6bba9..d179c28 100644
--- a/ql/src/test/results/clientpositive/cbo_union_view.q.out
+++ b/ql/src/test/results/clientpositive/cbo_union_view.q.out
@@ -64,6 +64,8 @@ STAGE PLANS:
       Map Operator Tree:
           TableScan
             alias: src_union_1
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: (key = 86) (type: boolean)
@@ -87,6 +89,8 @@ STAGE PLANS:
                           serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
           TableScan
             alias: src_union_2
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: (key = 86) (type: boolean)
@@ -110,6 +114,8 @@ STAGE PLANS:
                           serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
           TableScan
             alias: src_union_3
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: (key = 86) (type: boolean)
@@ -152,6 +158,8 @@ STAGE PLANS:
       Map Operator Tree:
           TableScan
             alias: src_union_1
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: ((key = 86) and (ds = '1')) (type: boolean)
@@ -175,6 +183,8 @@ STAGE PLANS:
                           serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
           TableScan
             alias: src_union_2
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: ((key = 86) and (ds = '1')) (type: boolean)
@@ -198,6 +208,8 @@ STAGE PLANS:
                           serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
           TableScan
             alias: src_union_3
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: ((key = 86) and (ds = '1')) (type: boolean)

http://git-wip-us.apache.org/repos/asf/hive/blob/f284b6d0/ql/src/test/results/clientpositive/ppd_union_view.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/ppd_union_view.q.out b/ql/src/test/results/clientpositive/ppd_union_view.q.out
index aa123d3..69234a1 100644
--- a/ql/src/test/results/clientpositive/ppd_union_view.q.out
+++ b/ql/src/test/results/clientpositive/ppd_union_view.q.out
@@ -149,6 +149,8 @@ STAGE PLANS:
       Map Operator Tree:
           TableScan
             alias: t1_old
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 14 Basic stats: COMPLETE Column stats: NONE
             GatherStats: false
             Filter Operator
@@ -170,6 +172,8 @@ STAGE PLANS:
                   auto parallelism: false
           TableScan
             alias: t1_mapping
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 12 Basic stats: COMPLETE Column stats: NONE
             GatherStats: false
             Filter Operator
@@ -322,6 +326,8 @@ STAGE PLANS:
       Map Operator Tree:
           TableScan
             alias: t1_new
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             GatherStats: false
             Filter Operator
@@ -477,6 +483,8 @@ STAGE PLANS:
       Map Operator Tree:
           TableScan
             alias: t1_old
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             GatherStats: false
             Filter Operator
@@ -498,6 +506,8 @@ STAGE PLANS:
                   auto parallelism: false
           TableScan
             alias: t1_mapping
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             GatherStats: false
             Filter Operator
@@ -554,6 +564,8 @@ STAGE PLANS:
       Map Operator Tree:
           TableScan
             alias: t1_new
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 11 Basic stats: COMPLETE Column stats: NONE
             GatherStats: false
             Select Operator

http://git-wip-us.apache.org/repos/asf/hive/blob/f284b6d0/ql/src/test/results/clientpositive/union_view.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/union_view.q.out b/ql/src/test/results/clientpositive/union_view.q.out
index 985ef9d..29f6758 100644
--- a/ql/src/test/results/clientpositive/union_view.q.out
+++ b/ql/src/test/results/clientpositive/union_view.q.out
@@ -181,6 +181,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_1
             filterExpr: ((key = 86) and (ds = '1')) (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats:
NONE
             Filter Operator
               predicate: (key = 86) (type: boolean)
@@ -205,6 +207,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_2
             filterExpr: ((key = 86) and (ds = '1')) (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: ((key = 86) and (ds = '1')) (type: boolean)
@@ -229,6 +233,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_3
             filterExpr: ((key = 86) and (ds = '1')) (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: ((key = 86) and (ds = '1')) (type: boolean)
@@ -294,6 +300,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_1
             filterExpr: ((key = 86) and (ds = '2')) (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: ((key = 86) and (ds = '2')) (type: boolean)
@@ -318,6 +326,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_2
             filterExpr: ((key = 86) and (ds = '2')) (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1000 Data size: 10624 Basic stats: COMPLETE Column stats:
NONE
             Filter Operator
               predicate: (key = 86) (type: boolean)
@@ -342,6 +352,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_3
             filterExpr: ((key = 86) and (ds = '2')) (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: ((key = 86) and (ds = '2')) (type: boolean)
@@ -407,6 +419,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_1
             filterExpr: ((key = 86) and (ds = '3')) (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: ((key = 86) and (ds = '3')) (type: boolean)
@@ -431,6 +445,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_2
             filterExpr: ((key = 86) and (ds = '3')) (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: ((key = 86) and (ds = '3')) (type: boolean)
@@ -455,6 +471,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_3
             filterExpr: ((key = 86) and (ds = '3')) (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1000 Data size: 10624 Basic stats: COMPLETE Column stats:
NONE
             Filter Operator
               predicate: (key = 86) (type: boolean)
@@ -524,6 +542,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_1
             filterExpr: ((key = 86) and ds is not null) (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats:
NONE
             Filter Operator
               predicate: (key = 86) (type: boolean)
@@ -548,6 +568,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_2
             filterExpr: ((key = 86) and ds is not null) (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1000 Data size: 10624 Basic stats: COMPLETE Column stats:
NONE
             Filter Operator
               predicate: (key = 86) (type: boolean)
@@ -572,6 +594,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_3
             filterExpr: ((key = 86) and ds is not null) (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1000 Data size: 10624 Basic stats: COMPLETE Column stats:
NONE
             Filter Operator
               predicate: (key = 86) (type: boolean)
@@ -693,6 +717,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_1
             filterExpr: (ds = '1') (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats:
NONE
             Select Operator
               Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats:
NONE
@@ -712,6 +738,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_2
             filterExpr: (ds = '1') (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: (ds = '1') (type: boolean)
@@ -734,6 +762,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_3
             filterExpr: (ds = '1') (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: (ds = '1') (type: boolean)
@@ -808,6 +838,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_1
             filterExpr: (ds = '2') (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: (ds = '2') (type: boolean)
@@ -830,6 +862,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_2
             filterExpr: (ds = '2') (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1000 Data size: 10624 Basic stats: COMPLETE Column stats:
NONE
             Select Operator
               Statistics: Num rows: 1000 Data size: 10624 Basic stats: COMPLETE Column stats:
NONE
@@ -849,6 +883,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_3
             filterExpr: (ds = '2') (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: (ds = '2') (type: boolean)
@@ -923,6 +959,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_1
             filterExpr: (ds = '3') (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: (ds = '3') (type: boolean)
@@ -945,6 +983,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_2
             filterExpr: (ds = '3') (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: (ds = '3') (type: boolean)
@@ -967,6 +1007,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_3
             filterExpr: (ds = '3') (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1000 Data size: 10624 Basic stats: COMPLETE Column stats:
NONE
             Select Operator
               Statistics: Num rows: 1000 Data size: 10624 Basic stats: COMPLETE Column stats:
NONE
@@ -1043,6 +1085,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_1
             filterExpr: ((key = 86) and (ds = '4')) (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: ((key = 86) and (ds = '4')) (type: boolean)
@@ -1067,6 +1111,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_2
             filterExpr: ((key = 86) and (ds = '4')) (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: ((key = 86) and (ds = '4')) (type: boolean)
@@ -1091,6 +1137,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_3
             filterExpr: ((key = 86) and (ds = '4')) (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats:
NONE
             Filter Operator
               predicate: (key = 86) (type: boolean)
@@ -1155,6 +1203,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_1
             filterExpr: (ds = '4') (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: (ds = '4') (type: boolean)
@@ -1177,6 +1227,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_2
             filterExpr: (ds = '4') (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE
             Filter Operator
               predicate: (ds = '4') (type: boolean)
@@ -1199,6 +1251,8 @@ STAGE PLANS:
           TableScan
             alias: src_union_3
             filterExpr: (ds = '4') (type: boolean)
+            properties:
+              insideView TRUE
             Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats:
NONE
             Select Operator
               Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats:
NONE


Mime
View raw message