You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jc...@apache.org on 2015/07/22 19:27:20 UTC

hive git commit: HIVE-9613: Left join query plan outputs wrong column when using subquery (Jesus Camacho Rodriguez, reviewed by Gunther Hagleitner)

Repository: hive
Updated Branches:
  refs/heads/branch-1.1 2f0ae24b7 -> afab13323


HIVE-9613: Left join query plan outputs wrong column when using subquery (Jesus Camacho Rodriguez, reviewed by Gunther Hagleitner)


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

Branch: refs/heads/branch-1.1
Commit: afab133233b716151b7d9af39fd7c25d2817e8a9
Parents: 2f0ae24
Author: Jesus Camacho Rodriguez <jc...@apache.org>
Authored: Wed Jul 22 18:26:38 2015 +0100
Committer: Jesus Camacho Rodriguez <jc...@apache.org>
Committed: Wed Jul 22 18:26:38 2015 +0100

----------------------------------------------------------------------
 .../hadoop/hive/ql/parse/RowResolver.java       |   8 +
 ql/src/test/queries/clientpositive/join42.q     |  45 +++
 ql/src/test/results/clientpositive/join42.q.out | 345 +++++++++++++++++++
 3 files changed, 398 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/afab1332/ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java
index 469dc9f..ad0c612 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java
@@ -97,6 +97,14 @@ public class RowResolver implements Serializable{
 
   public void put(String tab_alias, String col_alias, ColumnInfo colInfo) {
     if (!addMappingOnly(tab_alias, col_alias, colInfo)) {
+      //Make sure that the table alias and column alias are stored
+      //in the column info
+      if (tab_alias != null) {
+        colInfo.setTabAlias(tab_alias.toLowerCase());
+      }
+      if (col_alias != null) {
+        colInfo.setAlias(col_alias.toLowerCase());
+      }
       rowSchema.getSignature().add(colInfo);
     }
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/afab1332/ql/src/test/queries/clientpositive/join42.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/join42.q b/ql/src/test/queries/clientpositive/join42.q
new file mode 100644
index 0000000..ee96136
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/join42.q
@@ -0,0 +1,45 @@
+set hive.cbo.enable=false;
+
+create table taba(
+a01 string,
+a02 string,
+a03 string);
+
+create table tabb(
+b01 string);
+
+create table tabc(
+c01 string,
+c02 string);
+
+create table tabd(
+d01 string);
+
+explain
+select a01, * from
+(select a01, a02, a03 from taba) ta
+
+join
+(select b01 from tabb) tb
+on (ta.a02=tb.b01)
+
+join tabc tc
+on (tb.b01=tc.c01)
+
+left outer join
+(select d01 from tabd ) td
+on (td.d01 = tc.c02);
+
+explain select a01, * from
+(select a01, a02, a03 from taba) ta
+
+join
+(select b01 from tabb) tb
+on (ta.a02=tb.b01)
+
+join tabc tc
+on (tb.b01=tc.c01)
+
+join
+(select d01 from tabd ) td
+on (td.d01 = tc.c02);

http://git-wip-us.apache.org/repos/asf/hive/blob/afab1332/ql/src/test/results/clientpositive/join42.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/join42.q.out b/ql/src/test/results/clientpositive/join42.q.out
new file mode 100644
index 0000000..9f278a9
--- /dev/null
+++ b/ql/src/test/results/clientpositive/join42.q.out
@@ -0,0 +1,345 @@
+PREHOOK: query: create table taba(
+a01 string,
+a02 string,
+a03 string)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@taba
+POSTHOOK: query: create table taba(
+a01 string,
+a02 string,
+a03 string)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@taba
+PREHOOK: query: create table tabb(
+b01 string)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@tabb
+POSTHOOK: query: create table tabb(
+b01 string)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@tabb
+PREHOOK: query: create table tabc(
+c01 string,
+c02 string)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@tabc
+POSTHOOK: query: create table tabc(
+c01 string,
+c02 string)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@tabc
+PREHOOK: query: create table tabd(
+d01 string)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@tabd
+POSTHOOK: query: create table tabd(
+d01 string)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@tabd
+PREHOOK: query: explain
+select a01, * from
+(select a01, a02, a03 from taba) ta
+
+join
+(select b01 from tabb) tb
+on (ta.a02=tb.b01)
+
+join tabc tc
+on (tb.b01=tc.c01)
+
+left outer join
+(select d01 from tabd ) td
+on (td.d01 = tc.c02)
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select a01, * from
+(select a01, a02, a03 from taba) ta
+
+join
+(select b01 from tabb) tb
+on (ta.a02=tb.b01)
+
+join tabc tc
+on (tb.b01=tc.c01)
+
+left outer join
+(select d01 from tabd ) td
+on (td.d01 = tc.c02)
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-2 depends on stages: Stage-1
+  Stage-0 depends on stages: Stage-2
+
+STAGE PLANS:
+  Stage: Stage-1
+    Map Reduce
+      Map Operator Tree:
+          TableScan
+            alias: tc
+            Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+            Filter Operator
+              predicate: c01 is not null (type: boolean)
+              Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+              Reduce Output Operator
+                key expressions: c01 (type: string)
+                sort order: +
+                Map-reduce partition columns: c01 (type: string)
+                Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+                value expressions: c02 (type: string)
+          TableScan
+            alias: tabb
+            Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+            Filter Operator
+              predicate: b01 is not null (type: boolean)
+              Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+              Select Operator
+                expressions: b01 (type: string)
+                outputColumnNames: _col0
+                Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+                Reduce Output Operator
+                  key expressions: _col0 (type: string)
+                  sort order: +
+                  Map-reduce partition columns: _col0 (type: string)
+                  Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+          TableScan
+            alias: taba
+            Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+            Filter Operator
+              predicate: a02 is not null (type: boolean)
+              Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+              Select Operator
+                expressions: a01 (type: string), a02 (type: string), a03 (type: string)
+                outputColumnNames: _col0, _col1, _col2
+                Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+                Reduce Output Operator
+                  key expressions: _col1 (type: string)
+                  sort order: +
+                  Map-reduce partition columns: _col1 (type: string)
+                  Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+                  value expressions: _col0 (type: string), _col2 (type: string)
+      Reduce Operator Tree:
+        Join Operator
+          condition map:
+               Inner Join 0 to 1
+               Inner Join 1 to 2
+          condition expressions:
+            0 {VALUE._col0} {KEY.reducesinkkey0} {VALUE._col1}
+            1 {KEY.reducesinkkey0}
+            2 {KEY.reducesinkkey0} {VALUE._col0}
+          outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
+          Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+          File Output Operator
+            compressed: false
+            table:
+                input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+
+  Stage: Stage-2
+    Map Reduce
+      Map Operator Tree:
+          TableScan
+            Reduce Output Operator
+              key expressions: _col5 (type: string)
+              sort order: +
+              Map-reduce partition columns: _col5 (type: string)
+              Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+              value expressions: _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: string), _col4 (type: string)
+          TableScan
+            alias: tabd
+            Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+            Select Operator
+              expressions: d01 (type: string)
+              outputColumnNames: _col0
+              Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+              Reduce Output Operator
+                key expressions: _col0 (type: string)
+                sort order: +
+                Map-reduce partition columns: _col0 (type: string)
+                Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+      Reduce Operator Tree:
+        Join Operator
+          condition map:
+               Left Outer Join0 to 1
+          condition expressions:
+            0 {VALUE._col0} {VALUE._col1} {VALUE._col2} {VALUE._col3} {VALUE._col4} {KEY.reducesinkkey0}
+            1 {KEY.reducesinkkey0}
+          outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col9
+          Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+          Select Operator
+            expressions: _col0 (type: string), _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: string), _col4 (type: string), _col5 (type: string), _col9 (type: string)
+            outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7
+            Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+            File Output Operator
+              compressed: false
+              Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+              table:
+                  input format: org.apache.hadoop.mapred.TextInputFormat
+                  output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
+                  serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: explain select a01, * from
+(select a01, a02, a03 from taba) ta
+
+join
+(select b01 from tabb) tb
+on (ta.a02=tb.b01)
+
+join tabc tc
+on (tb.b01=tc.c01)
+
+join
+(select d01 from tabd ) td
+on (td.d01 = tc.c02)
+PREHOOK: type: QUERY
+POSTHOOK: query: explain select a01, * from
+(select a01, a02, a03 from taba) ta
+
+join
+(select b01 from tabb) tb
+on (ta.a02=tb.b01)
+
+join tabc tc
+on (tb.b01=tc.c01)
+
+join
+(select d01 from tabd ) td
+on (td.d01 = tc.c02)
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-2 depends on stages: Stage-1
+  Stage-0 depends on stages: Stage-2
+
+STAGE PLANS:
+  Stage: Stage-1
+    Map Reduce
+      Map Operator Tree:
+          TableScan
+            alias: tc
+            Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+            Filter Operator
+              predicate: (c01 is not null and c02 is not null) (type: boolean)
+              Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+              Reduce Output Operator
+                key expressions: c01 (type: string)
+                sort order: +
+                Map-reduce partition columns: c01 (type: string)
+                Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+                value expressions: c02 (type: string)
+          TableScan
+            alias: tabb
+            Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+            Filter Operator
+              predicate: b01 is not null (type: boolean)
+              Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+              Select Operator
+                expressions: b01 (type: string)
+                outputColumnNames: _col0
+                Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+                Reduce Output Operator
+                  key expressions: _col0 (type: string)
+                  sort order: +
+                  Map-reduce partition columns: _col0 (type: string)
+                  Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+          TableScan
+            alias: taba
+            Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+            Filter Operator
+              predicate: a02 is not null (type: boolean)
+              Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+              Select Operator
+                expressions: a01 (type: string), a02 (type: string), a03 (type: string)
+                outputColumnNames: _col0, _col1, _col2
+                Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+                Reduce Output Operator
+                  key expressions: _col1 (type: string)
+                  sort order: +
+                  Map-reduce partition columns: _col1 (type: string)
+                  Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+                  value expressions: _col0 (type: string), _col2 (type: string)
+      Reduce Operator Tree:
+        Join Operator
+          condition map:
+               Inner Join 0 to 1
+               Inner Join 1 to 2
+          condition expressions:
+            0 {VALUE._col0} {KEY.reducesinkkey0} {VALUE._col1}
+            1 {KEY.reducesinkkey0}
+            2 {KEY.reducesinkkey0} {VALUE._col0}
+          outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
+          Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+          File Output Operator
+            compressed: false
+            table:
+                input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+
+  Stage: Stage-2
+    Map Reduce
+      Map Operator Tree:
+          TableScan
+            Reduce Output Operator
+              key expressions: _col5 (type: string)
+              sort order: +
+              Map-reduce partition columns: _col5 (type: string)
+              Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+              value expressions: _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: string), _col4 (type: string)
+          TableScan
+            alias: tabd
+            Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+            Filter Operator
+              predicate: d01 is not null (type: boolean)
+              Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+              Select Operator
+                expressions: d01 (type: string)
+                outputColumnNames: _col0
+                Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+                Reduce Output Operator
+                  key expressions: _col0 (type: string)
+                  sort order: +
+                  Map-reduce partition columns: _col0 (type: string)
+                  Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+      Reduce Operator Tree:
+        Join Operator
+          condition map:
+               Inner Join 0 to 1
+          condition expressions:
+            0 {VALUE._col0} {VALUE._col1} {VALUE._col2} {VALUE._col3} {VALUE._col4} {KEY.reducesinkkey0}
+            1 {KEY.reducesinkkey0}
+          outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col9
+          Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+          Select Operator
+            expressions: _col0 (type: string), _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: string), _col4 (type: string), _col5 (type: string), _col9 (type: string)
+            outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7
+            Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+            File Output Operator
+              compressed: false
+              Statistics: Num rows: 0 Data size: 0 Basic stats: NONE Column stats: NONE
+              table:
+                  input format: org.apache.hadoop.mapred.TextInputFormat
+                  output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
+                  serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+