hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject [33/43] hive git commit: HIVE-12407: Check fetch property to determine if a SortLimit contains a limit operation (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)
Date Tue, 17 Nov 2015 20:19:44 GMT
HIVE-12407: Check fetch property to determine if a SortLimit contains a limit operation (Jesus
Camacho Rodriguez, reviewed by Ashutosh Chauhan)


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

Branch: refs/heads/master-fixed
Commit: 87ceba6bb082dcb9ca1d6f67dd2d536659a2dd9d
Parents: f759223
Author: Jesus Camacho Rodriguez <jcamacho@apache.org>
Authored: Sat Nov 14 08:46:18 2015 +0100
Committer: Owen O'Malley <omalley@apache.org>
Committed: Tue Nov 17 12:18:34 2015 -0800

----------------------------------------------------------------------
 .../ql/optimizer/calcite/HiveCalciteUtil.java   | 20 ++++++++++++++------
 .../translator/PlanModifierForASTConv.java      | 10 +++++-----
 2 files changed, 19 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/87ceba6b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveCalciteUtil.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveCalciteUtil.java
b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveCalciteUtil.java
index 90c2067..e1b60b0 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveCalciteUtil.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveCalciteUtil.java
@@ -32,7 +32,6 @@ import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rel.core.Join;
 import org.apache.calcite.rel.core.RelFactories.ProjectFactory;
 import org.apache.calcite.rel.core.Sort;
-import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rel.type.RelDataTypeField;
 import org.apache.calcite.rex.RexBuilder;
 import org.apache.calcite.rex.RexCall;
@@ -45,7 +44,6 @@ import org.apache.calcite.rex.RexLocalRef;
 import org.apache.calcite.rex.RexNode;
 import org.apache.calcite.rex.RexOver;
 import org.apache.calcite.rex.RexRangeRef;
-import org.apache.calcite.rex.RexShuttle;
 import org.apache.calcite.rex.RexVisitor;
 import org.apache.calcite.rex.RexVisitorImpl;
 import org.apache.calcite.sql.SqlKind;
@@ -54,8 +52,6 @@ import org.apache.calcite.sql.validate.SqlValidatorUtil;
 import org.apache.calcite.util.ImmutableBitSet;
 import org.apache.calcite.util.Pair;
 import org.apache.calcite.util.Util;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.ql.metadata.VirtualColumn;
 import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveMultiJoin;
@@ -65,6 +61,8 @@ import org.apache.hadoop.hive.ql.parse.ASTNode;
 import org.apache.hadoop.hive.ql.parse.HiveParser;
 import org.apache.hadoop.hive.ql.parse.ParseUtils;
 import org.apache.hadoop.hive.ql.plan.ExprNodeDesc;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Function;
 import com.google.common.collect.ImmutableList;
@@ -566,16 +564,26 @@ public class HiveCalciteUtil {
     }
   }
 
+  public static boolean pureLimitRelNode(RelNode rel) {
+    return limitRelNode(rel) && !orderRelNode(rel);
+  }
+
+  public static boolean pureOrderRelNode(RelNode rel) {
+    return !limitRelNode(rel) && orderRelNode(rel);
+  }
+
   public static boolean limitRelNode(RelNode rel) {
-    if ((rel instanceof Sort) && ((Sort) rel).getCollation().getFieldCollations().isEmpty())
+    if ((rel instanceof Sort) && ((Sort) rel).fetch != null) {
       return true;
+    }
 
     return false;
   }
 
   public static boolean orderRelNode(RelNode rel) {
-    if ((rel instanceof Sort) && !((Sort) rel).getCollation().getFieldCollations().isEmpty())
+    if ((rel instanceof Sort) && !((Sort) rel).getCollation().getFieldCollations().isEmpty())
{
       return true;
+    }
 
     return false;
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/87ceba6b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/PlanModifierForASTConv.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/PlanModifierForASTConv.java
b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/PlanModifierForASTConv.java
index 29e08f8..b77beb8 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/PlanModifierForASTConv.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/PlanModifierForASTConv.java
@@ -301,9 +301,10 @@ public class PlanModifierForASTConv {
   private static boolean validSortParent(RelNode sortNode, RelNode parent) {
     boolean validParent = true;
 
-    if (parent != null && !(parent instanceof Project)
-        && !((parent instanceof Sort) || HiveCalciteUtil.orderRelNode(parent)))
+    if (parent != null && !(parent instanceof Project) &&
+        !(HiveCalciteUtil.pureLimitRelNode(parent) && HiveCalciteUtil.pureOrderRelNode(sortNode)))
{
       validParent = false;
+    }
 
     return validParent;
   }
@@ -312,9 +313,8 @@ public class PlanModifierForASTConv {
     boolean validChild = true;
     RelNode child = sortNode.getInput();
 
-    if (!(HiveCalciteUtil.limitRelNode(sortNode) && HiveCalciteUtil.orderRelNode(child)
-            && HiveCalciteUtil.limitRelNode(child))
-        && !(child instanceof Project)) {
+    if (!(child instanceof Project) &&
+        !(HiveCalciteUtil.pureLimitRelNode(sortNode) && HiveCalciteUtil.pureOrderRelNode(child)))
{
       validChild = false;
     }
 


Mime
View raw message