drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [1/5] drill git commit: DRILL-3702: Fix partition pruning rule when the pruning filter expression has non-nullable type.
Date Wed, 26 Aug 2015 22:08:17 GMT
Repository: drill
Updated Branches:
  refs/heads/master 18ce02166 -> 21fbb28ea


DRILL-3702: Fix partition pruning rule when the pruning filter expression has non-nullable
type.


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

Branch: refs/heads/master
Commit: ec4ffb4412251900343c56a9d811190f88516a9f
Parents: 18ce021
Author: Jinfeng Ni <jni@apache.org>
Authored: Mon Aug 24 15:13:12 2015 -0700
Committer: Jinfeng Ni <jni@apache.org>
Committed: Wed Aug 26 12:07:46 2015 -0700

----------------------------------------------------------------------
 .../planner/logical/partition/PruneScanRule.java    | 16 ++++++++++++++--
 .../java/org/apache/drill/TestPartitionFilter.java  |  6 ++++++
 2 files changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/ec4ffb44/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/partition/PruneScanRule.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/partition/PruneScanRule.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/partition/PruneScanRule.java
index b70e85c..1c5c7e4 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/partition/PruneScanRule.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/partition/PruneScanRule.java
@@ -28,6 +28,7 @@ import org.apache.calcite.util.BitSets;
 import org.apache.drill.common.expression.ErrorCollectorImpl;
 import org.apache.drill.common.expression.LogicalExpression;
 import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.types.TypeProtos;
 import org.apache.drill.common.types.TypeProtos.MajorType;
 import org.apache.drill.common.types.TypeProtos.MinorType;
 import org.apache.drill.common.types.Types;
@@ -207,9 +208,20 @@ public abstract class PruneScanRule extends StoragePluginOptimizerRule
{
 
       // materialize the expression
       logger.debug("Attempting to prune {}", pruneCondition);
-      LogicalExpression expr = DrillOptiq.toDrill(new DrillParseContext(settings), scanRel,
pruneCondition);
-      ErrorCollectorImpl errors = new ErrorCollectorImpl();
+      final LogicalExpression expr = DrillOptiq.toDrill(new DrillParseContext(settings),
scanRel, pruneCondition);
+      final ErrorCollectorImpl errors = new ErrorCollectorImpl();
+
       LogicalExpression materializedExpr = ExpressionTreeMaterializer.materialize(expr, container,
errors, optimizerContext.getFunctionRegistry());
+      // Make sure pruneCondition's materialized expression is always of BitType, so that
+      // it's same as the type of output vector.
+      if (materializedExpr.getMajorType().getMode() == TypeProtos.DataMode.REQUIRED) {
+        materializedExpr = ExpressionTreeMaterializer.convertToNullableType(
+            materializedExpr,
+            materializedExpr.getMajorType().getMinorType(),
+            optimizerContext.getFunctionRegistry(),
+            errors);
+      }
+
       if (errors.getErrorCount() != 0) {
         logger.warn("Failure while materializing expression [{}].  Errors: {}", expr, errors);
       }

http://git-wip-us.apache.org/repos/asf/drill/blob/ec4ffb44/exec/java-exec/src/test/java/org/apache/drill/TestPartitionFilter.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestPartitionFilter.java b/exec/java-exec/src/test/java/org/apache/drill/TestPartitionFilter.java
index 5475247..e1ebbc0 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/TestPartitionFilter.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestPartitionFilter.java
@@ -283,4 +283,10 @@ public class TestPartitionFilter extends PlanTestBase {
     testIncludeFilter(query, 8, "Filter", 24);
   }
 
+  @Test // DRILL-3702
+  public void testPartitionFilterWithNonNullabeFilterExpr() throws Exception {
+    String query = String.format("select dir0, dir1, o_custkey, o_orderdate from dfs_test.`%s/multilevel/parquet`
where concat(dir0, '') = '1994' and concat(dir1, '') = 'Q1'", TEST_RES_PATH);
+    testExcludeFilter(query, 1, "Filter", 10);
+  }
+
 }
\ No newline at end of file


Mime
View raw message