drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [2/2] drill git commit: DRILL-3876: Skip SplitUpComplexExpression logic only when there is one complex expression at tope level of expression tree.
Date Wed, 14 Oct 2015 23:19:03 GMT
DRILL-3876: Skip SplitUpComplexExpression logic only when there is one complex expression at
tope level of expression tree.


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

Branch: refs/heads/master
Commit: 202a8e1544bebcfcab138ac8c85c1690389c3a73
Parents: 6bc9111
Author: Jinfeng Ni <jni@apache.org>
Authored: Mon Oct 12 17:23:48 2015 -0700
Committer: Jinfeng Ni <jni@apache.org>
Committed: Wed Oct 14 14:47:06 2015 -0700

----------------------------------------------------------------------
 .../visitor/SplitUpComplexExpressions.java      | 24 +++++++++++++++++++-
 .../exec/physical/impl/flatten/TestFlatten.java | 18 +++++++++++++++
 2 files changed, 41 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/202a8e15/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/SplitUpComplexExpressions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/SplitUpComplexExpressions.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/SplitUpComplexExpressions.java
index b79836d..a3952cb 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/SplitUpComplexExpressions.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/SplitUpComplexExpressions.java
@@ -20,6 +20,7 @@ package org.apache.drill.exec.planner.physical.visitor;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
 
+import org.apache.calcite.rex.RexCall;
 import org.apache.calcite.tools.RelConversionException;
 
 import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry;
@@ -94,7 +95,7 @@ public class SplitUpComplexExpressions extends BasePrelVisitor<Prel,
Object, Rel
     }
     List<RexNode> complexExprs = exprSplitter.getComplexExprs();
 
-    if (complexExprs.size() == 1) {
+    if (complexExprs.size() == 1 && findTopComplexFunc(project.getChildExps()).size()
== 1) {
       return project;
     }
 
@@ -142,4 +143,25 @@ public class SplitUpComplexExpressions extends BasePrelVisitor<Prel,
Object, Rel
     }
     return (Prel) project.copy(project.getTraitSet(), originalInput, exprList, new RelRecordType(origRelDataTypes));
   }
+
+  /**
+   *  Find the list of expressions where Complex type function is at top level.
+   */
+  private List<RexNode> findTopComplexFunc(List<RexNode> exprs) {
+    final List<RexNode> topComplexFuncs = new ArrayList<>();
+
+    for (RexNode exp : exprs) {
+      if (exp instanceof RexCall) {
+        RexCall call = (RexCall) exp;
+        String functionName = call.getOperator().getName();
+
+        if (funcReg.isFunctionComplexOutput(functionName) ) {
+          topComplexFuncs.add(exp);
+        }
+      }
+    }
+
+    return topComplexFuncs;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/202a8e15/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 39e36eb..a17aae0 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
@@ -529,5 +529,23 @@ public class TestFlatten extends BaseTestQuery {
       .go();
   }
 
+  @Test
+  public void testFlattenWithScalarFunc() throws Exception {
+    final String query = "select flatten(t.l) + 1  as c1 from cp.`/jsoninput/input2.json`
t";
+
+    testBuilder()
+        .sqlQuery(query)
+        .unOrdered()
+        .baselineColumns("c1")
+        .baselineValues(5L)
+        .baselineValues(3L)
+        .baselineValues(5L)
+        .baselineValues(3L)
+        .baselineValues(5L)
+        .baselineValues(3L)
+        .go();
+
+  }
 
 }
+


Mime
View raw message