hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pxi...@apache.org
Subject hive git commit: HIVE-10183:: [CBO] self-join failing in a test case (Ashutosh Chauhan via Pengcheng Xiong)
Date Wed, 12 Aug 2015 20:26:55 GMT
Repository: hive
Updated Branches:
  refs/heads/branch-1.0 4e7260ba3 -> d5dcd3e3e


HIVE-10183:: [CBO] self-join failing in a test case (Ashutosh Chauhan via Pengcheng Xiong)


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

Branch: refs/heads/branch-1.0
Commit: d5dcd3e3eb2a5c8d932862ff43a5085cb8805186
Parents: 4e7260b
Author: Pengcheng Xiong <pxiong@apache.org>
Authored: Wed Aug 12 13:26:51 2015 -0700
Committer: Pengcheng Xiong <pxiong@apache.org>
Committed: Wed Aug 12 13:26:51 2015 -0700

----------------------------------------------------------------------
 .../translator/PlanModifierForASTConv.java      | 29 ++++++++++++++++++--
 1 file changed, 26 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/d5dcd3e3/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/PlanModifierForASTConv.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/PlanModifierForASTConv.java
b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/PlanModifierForASTConv.java
index 57f030b..98f3e26 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/PlanModifierForASTConv.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/PlanModifierForASTConv.java
@@ -30,6 +30,7 @@ import org.apache.hadoop.hive.ql.optimizer.optiq.OptiqSemanticException;
 import org.apache.hadoop.hive.ql.optimizer.optiq.reloperators.HiveAggregateRel;
 import org.apache.hadoop.hive.ql.optimizer.optiq.reloperators.HiveProjectRel;
 import org.apache.hadoop.hive.ql.optimizer.optiq.reloperators.HiveSortRel;
+import org.apache.hadoop.hive.ql.optimizer.optiq.reloperators.HiveTableScanRel;
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 import org.eigenbase.rel.AggregateCall;
 import org.eigenbase.rel.AggregateRelBase;
@@ -53,6 +54,7 @@ import org.eigenbase.reltype.RelDataTypeFactory;
 import org.eigenbase.rex.RexNode;
 import org.eigenbase.sql.SqlKind;
 import org.eigenbase.util.Pair;
+import org.apache.hadoop.hive.ql.optimizer.optiq.RelOptHiveTable;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
@@ -94,6 +96,23 @@ public class PlanModifierForASTConv {
     return newTopNode;
   }
 
+  private static String getTblAlias(RelNode rel) {
+
+    if (null == rel) {
+      return null;
+    }
+    if (rel instanceof HiveTableScanRel) {
+      return ((RelOptHiveTable)((HiveTableScanRel)rel).getTable()).getTableAlias();
+    }
+    if (rel instanceof HiveProjectRel) {
+      return null;
+    }
+    if (rel.getInputs().size() == 1) {
+      return getTblAlias(rel.getInput(0));
+    }
+    return null;
+  }
+
   private static void convertOpTree(RelNode rel, RelNode parent) {
 
     if (rel instanceof EmptyRel) {
@@ -104,10 +123,14 @@ public class PlanModifierForASTConv {
       if (!validJoinParent(rel, parent)) {
         introduceDerivedTable(rel, parent);
       }
+      String leftChild = getTblAlias(((JoinRelBase)rel).getLeft());
+      if (null != leftChild && leftChild.equalsIgnoreCase(getTblAlias(((JoinRelBase)rel).getRight())))
{
+        // introduce derived table above one child, if this is self-join
+        // since user provided aliases are lost at this point.
+        introduceDerivedTable(((JoinRelBase)rel).getLeft(), rel);
+      }
     } else if (rel instanceof MultiJoinRel) {
-      throw new RuntimeException("Found MultiJoinRel");
-    } else if (rel instanceof OneRowRelBase) {
-      throw new RuntimeException("Found OneRowRelBase");
+      throw new RuntimeException("Found MultiJoin");
     } else if (rel instanceof RelSubset) {
       throw new RuntimeException("Found RelSubset");
     } else if (rel instanceof SetOpRel) {


Mime
View raw message