drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [3/3] drill git commit: DRILL-3370: Flatten failure with a filter condition.
Date Mon, 29 Jun 2015 06:32:46 GMT
DRILL-3370: Flatten failure with a filter condition.

Fix required excluding flatten from the PushFilterPastProjectRule.


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

Branch: refs/heads/master
Commit: a915085e8a8b4255ff659086d047cc5dd874a5bf
Parents: 233faf2
Author: Jason Altekruse <altekrusejason@gmail.com>
Authored: Thu Jun 25 18:44:46 2015 -0700
Committer: Jason Altekruse <altekrusejason@gmail.com>
Committed: Sun Jun 28 22:28:32 2015 -0700

----------------------------------------------------------------------
 .../planner/logical/DrillPushFilterPastProjectRule.java | 12 +++++++-----
 .../drill/exec/physical/impl/flatten/TestFlatten.java   | 11 +++++++++++
 .../src/test/resources/flatten/drill-3370.json          |  5 +++++
 3 files changed, 23 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/a915085e/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillPushFilterPastProjectRule.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillPushFilterPastProjectRule.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillPushFilterPastProjectRule.java
index 3755ea1..0dba24e 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillPushFilterPastProjectRule.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillPushFilterPastProjectRule.java
@@ -37,14 +37,15 @@ public class DrillPushFilterPastProjectRule extends RelOptRule {
 
   public final static RelOptRule INSTANCE = new DrillPushFilterPastProjectRule();
 
-  private RexCall findItemOperator(
+  private RexCall findItemOrFlatten(
       final RexNode node,
       final List<RexNode> projExprs) {
     try {
       RexVisitor<Void> visitor =
           new RexVisitorImpl<Void>(true) {
         public Void visitCall(RexCall call) {
-          if ("item".equals(call.getOperator().getName().toLowerCase())) {
+          if ("item".equals(call.getOperator().getName().toLowerCase()) ||
+            "flatten".equals(call.getOperator().getName().toLowerCase())) {
             throw new Util.FoundOne(call); /* throw exception to interrupt tree walk (this
is similar to
                                               other utility methods in RexUtil.java */
           }
@@ -56,7 +57,8 @@ public class DrillPushFilterPastProjectRule extends RelOptRule {
           RexNode n = projExprs.get(index);
           if (n instanceof RexCall) {
             RexCall r = (RexCall) n;
-            if ("item".equals(r.getOperator().getName().toLowerCase())) {
+            if ("item".equals(r.getOperator().getName().toLowerCase()) ||
+                "flatten".equals(r.getOperator().getName().toLowerCase())) {
               throw new Util.FoundOne(r);
             }
           }
@@ -86,11 +88,11 @@ public class DrillPushFilterPastProjectRule extends RelOptRule {
     Filter filterRel = call.rel(0);
     Project projRel = call.rel(1);
 
-    // Don't push Filter past Project if the Filter is referencing an ITEM expression
+    // Don't push Filter past Project if the Filter is referencing an ITEM or a FLATTEN expression
     // from the Project.
     //\TODO: Ideally we should split up the filter conditions into ones that
     // reference the ITEM expression and ones that don't and push the latter past the Project
-    if (findItemOperator(filterRel.getCondition(), projRel.getProjects()) != null) {
+    if (findItemOrFlatten(filterRel.getCondition(), projRel.getProjects()) != null) {
       return;
     }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/a915085e/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java
index 5756e97..39e36eb 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java
@@ -196,6 +196,17 @@ public class TestFlatten extends BaseTestQuery {
   }
 
   @Test
+  public void drill3370() throws Exception {
+    testBuilder()
+        .sqlQuery("select a from (select flatten(arr) as a from cp.`/flatten/drill-3370.json`)
where a > 100")
+        .unOrdered()
+        .baselineColumns("a")
+        .baselineValues(131l)
+        .baselineValues(106l)
+        .go();
+  }
+
+  @Test
   @Ignore("not yet fixed")
   public void drill1660() throws Exception {
     test("select * from cp.`/flatten/empty-rm.json`");

http://git-wip-us.apache.org/repos/asf/drill/blob/a915085e/exec/java-exec/src/test/resources/flatten/drill-3370.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/flatten/drill-3370.json b/exec/java-exec/src/test/resources/flatten/drill-3370.json
new file mode 100644
index 0000000..381a394
--- /dev/null
+++ b/exec/java-exec/src/test/resources/flatten/drill-3370.json
@@ -0,0 +1,5 @@
+{"arr": [131]}
+{"arr": [1]}
+{"arr": [27]}
+{"arr": [79]}
+{"arr": [106]}


Mime
View raw message