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 2016/05/11 15:47:38 UTC

hive git commit: HIVE-13722: Add flag to detect constants to CBO pull up rules (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Repository: hive
Updated Branches:
  refs/heads/master b8e086f5e -> d8f3d33b0


HIVE-13722: Add flag to detect constants to CBO pull up rules (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/d8f3d33b
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/d8f3d33b
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/d8f3d33b

Branch: refs/heads/master
Commit: d8f3d33b0629b6db1dad85d23a5b7c49b43e1594
Parents: b8e086f
Author: Jesus Camacho Rodriguez <jc...@apache.org>
Authored: Wed May 11 15:28:14 2016 +0100
Committer: Jesus Camacho Rodriguez <jc...@apache.org>
Committed: Wed May 11 15:28:14 2016 +0100

----------------------------------------------------------------------
 .../calcite/rules/HiveSortLimitPullUpConstantsRule.java       | 7 +++++++
 .../optimizer/calcite/rules/HiveUnionPullUpConstantsRule.java | 7 +++++++
 2 files changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/d8f3d33b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortLimitPullUpConstantsRule.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortLimitPullUpConstantsRule.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortLimitPullUpConstantsRule.java
index d14b0ba..3be9b0a 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortLimitPullUpConstantsRule.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortLimitPullUpConstantsRule.java
@@ -108,6 +108,7 @@ public class HiveSortLimitPullUpConstantsRule extends RelOptRule {
     }
 
     // Create expressions for Project operators before and after the Sort
+    boolean atLeastOneConstant = false;
     List<RelDataTypeField> fields = sort.getInput().getRowType().getFieldList();
     List<Pair<RexNode, String>> newChildExprs = new ArrayList<>();
     List<RexNode> topChildExprs = new ArrayList<>();
@@ -116,6 +117,7 @@ public class HiveSortLimitPullUpConstantsRule extends RelOptRule {
       RexNode expr = rexBuilder.makeInputRef(sort.getInput(), i);
       RelDataTypeField field = fields.get(i);
       if (constants.containsKey(expr)) {
+        atLeastOneConstant = true;
         topChildExprs.add(constants.get(expr));
         topChildExprsFields.add(field.getName());
       } else {
@@ -125,6 +127,11 @@ public class HiveSortLimitPullUpConstantsRule extends RelOptRule {
       }
     }
 
+    // No constants were found
+    if (!atLeastOneConstant) {
+      return;
+    }
+
     // Update field collations
     final Mappings.TargetMapping mapping =
             RelOptUtil.permutation(Pair.left(newChildExprs), sort.getInput().getRowType()).inverse();

http://git-wip-us.apache.org/repos/asf/hive/blob/d8f3d33b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveUnionPullUpConstantsRule.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveUnionPullUpConstantsRule.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveUnionPullUpConstantsRule.java
index 3155cb1..2552f87 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveUnionPullUpConstantsRule.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveUnionPullUpConstantsRule.java
@@ -96,6 +96,7 @@ public class HiveUnionPullUpConstantsRule extends RelOptRule {
     }
 
     // Create expressions for Project operators before and after the Union
+    boolean atLeastOneConstant = false;
     List<RelDataTypeField> fields = union.getRowType().getFieldList();
     List<Pair<RexNode, String>> newChildExprs = new ArrayList<>();
     List<RexNode> topChildExprs = new ArrayList<>();
@@ -104,6 +105,7 @@ public class HiveUnionPullUpConstantsRule extends RelOptRule {
       RexNode expr = rexBuilder.makeInputRef(union, i);
       RelDataTypeField field = fields.get(i);
       if (constants.containsKey(expr)) {
+        atLeastOneConstant = true;
         topChildExprs.add(constants.get(expr));
         topChildExprsFields.add(field.getName());
       } else {
@@ -113,6 +115,11 @@ public class HiveUnionPullUpConstantsRule extends RelOptRule {
       }
     }
 
+    // No constants were found
+    if (!atLeastOneConstant) {
+      return;
+    }
+
     // Update top Project positions
     final Mappings.TargetMapping mapping =
             RelOptUtil.permutation(Pair.left(newChildExprs), union.getInput(0).getRowType()).inverse();