drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amansi...@apache.org
Subject drill git commit: DRILL-3220: IOB Exception - Need a better error message
Date Mon, 15 Jun 2015 20:27:27 GMT
Repository: drill
Updated Branches:
  refs/heads/master d5dc322d5 -> 288c95223


DRILL-3220: IOB Exception - Need a better error message


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

Branch: refs/heads/master
Commit: 288c9522327474765c0c5497ba38a63959621d77
Parents: d5dc322
Author: adeneche <adeneche@gmail.com>
Authored: Fri Jun 5 17:12:57 2015 -0700
Committer: Aman Sinha <asinha@maprtech.com>
Committed: Mon Jun 15 13:11:43 2015 -0700

----------------------------------------------------------------------
 .../exec/planner/logical/DrillWindowRule.java   |  4 +---
 .../drill/exec/planner/physical/WindowPrel.java |  7 +++---
 .../physical/impl/window/TestWindowFrame.java   | 23 ++++++++++----------
 exec/java-exec/src/test/resources/window/q1.sql |  6 +++++
 exec/java-exec/src/test/resources/window/q2.sql | 10 +++++++++
 .../src/test/resources/window/q3218.sql         |  5 +++++
 .../src/test/resources/window/q3220.sql         |  3 +++
 7 files changed, 41 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/288c9522/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillWindowRule.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillWindowRule.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillWindowRule.java
index 76939d9..1cefcd9 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillWindowRule.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillWindowRule.java
@@ -18,14 +18,12 @@
 
 package org.apache.drill.exec.planner.logical;
 
-import com.google.common.collect.Lists;
 import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rel.core.Window;
 import org.apache.calcite.plan.Convention;
 import org.apache.calcite.plan.RelOptRule;
 import org.apache.calcite.plan.RelOptRuleCall;
 import org.apache.calcite.plan.RelTraitSet;
-import org.apache.calcite.rex.RexLiteral;
 
 public class DrillWindowRule extends RelOptRule {
   public static final RelOptRule INSTANCE = new DrillWindowRule();
@@ -45,7 +43,7 @@ public class DrillWindowRule extends RelOptRule {
             window.getCluster(),
             traits,
             convertedInput,
-            Lists.<RexLiteral>newArrayList(),
+            window.constants,
             window.getRowType(),
             window.groups));
   }

http://git-wip-us.apache.org/repos/asf/drill/blob/288c9522/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/WindowPrel.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/WindowPrel.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/WindowPrel.java
index 4f6551a..122dee8 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/WindowPrel.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/WindowPrel.java
@@ -109,15 +109,16 @@ public class WindowPrel extends DrillWindowRelBase implements Prel {
   protected LogicalExpression toDrill(AggregateCall call, List<String> fn) {
     List<LogicalExpression> args = Lists.newArrayList();
     for (Integer i : call.getArgList()) {
-      args.add(new FieldReference(fn.get(i)));
+      if (i < fn.size()) {
+        args.add(new FieldReference(fn.get(i)));
+      }
     }
 
     // for count(1).
     if (args.isEmpty()) {
       args.add(new ValueExpressions.LongExpression(1l));
     }
-    LogicalExpression expr = new FunctionCall(call.getAggregation().getName().toLowerCase(),
args, ExpressionPosition.UNKNOWN);
-    return expr;
+    return new FunctionCall(call.getAggregation().getName().toLowerCase(), args, ExpressionPosition.UNKNOWN);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/drill/blob/288c9522/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/window/TestWindowFrame.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/window/TestWindowFrame.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/window/TestWindowFrame.java
index 4295002..aefe77d 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/window/TestWindowFrame.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/window/TestWindowFrame.java
@@ -30,10 +30,6 @@ import org.junit.Test;
 public class TestWindowFrame extends BaseTestQuery {
 
   private static final String TEST_RES_PATH = TestTools.getWorkingPath() + "/src/test/resources";
-  private static final String QUERY_NO_ORDERBY =
-    "select count(*) over pos_win `count`, sum(salary) over pos_win `sum` from dfs_test.`%s/window/%s`
window pos_win as (partition by position_id)";
-  private static final String QUERY_ORDERBY =
-    "select count(*) over pos_win `count`, sum(salary) over pos_win `sum`, row_number() over
pos_win `row_number`, rank() over pos_win `rank`, dense_rank() over pos_win `dense_rank`,
cume_dist() over pos_win `cume_dist`, percent_rank() over pos_win `percent_rank`  from dfs_test.`%s/window/%s`
window pos_win as (partition by position_id order by sub)";
 
   @BeforeClass
   public static void setupMSortBatchSize() {
@@ -46,7 +42,7 @@ public class TestWindowFrame extends BaseTestQuery {
 
   private DrillTestWrapper buildWindowQuery(final String tableName) throws Exception {
     return testBuilder()
-      .sqlQuery(String.format(QUERY_NO_ORDERBY, TEST_RES_PATH, tableName))
+      .sqlQuery(String.format(getFile("window/q1.sql"), TEST_RES_PATH, tableName))
       .ordered()
       .csvBaselineFile("window/" + tableName + ".tsv")
       .baselineColumns("count", "sum")
@@ -55,7 +51,7 @@ public class TestWindowFrame extends BaseTestQuery {
 
   private DrillTestWrapper buildWindowWithOrderByQuery(final String tableName) throws Exception
{
     return testBuilder()
-      .sqlQuery(String.format(QUERY_ORDERBY, TEST_RES_PATH, tableName))
+      .sqlQuery(String.format(getFile("window/q2.sql"), TEST_RES_PATH, tableName))
       .ordered()
       .csvBaselineFile("window/" + tableName + ".subs.tsv")
       .baselineColumns("count", "sum", "row_number", "rank", "dense_rank", "cume_dist", "percent_rank")
@@ -163,11 +159,6 @@ public class TestWindowFrame extends BaseTestQuery {
     runTest("b4.p4", true);
   }
 
-  @Test // DRILL-3218
-  public void testMaxVarChar() throws Exception {
-    test("select max(cast(columns[2] as char(2))) over(partition by cast(columns[2] as char(2))
order by cast(columns[0] as int)) from dfs_test.`%s/window/allData.csv`", TEST_RES_PATH);
-  }
-
   @Test // DRILL-1862
   public void testEmptyPartitionBy() throws Exception {
     test("SELECT employee_id, position_id, salary, SUM(salary) OVER(ORDER BY position_id)
FROM cp.`employee.json` LIMIT 10");
@@ -178,4 +169,14 @@ public class TestWindowFrame extends BaseTestQuery {
     test("SELECT employee_id, position_id, salary, SUM(salary) OVER() FROM cp.`employee.json`
LIMIT 10");
   }
 
+  @Test // DRILL-3218
+  public void testMaxVarChar() throws Exception {
+    test(getFile("window/q3218.sql"), TEST_RES_PATH);
+  }
+
+  @Test // DRILL-3220
+  public void testCountConst() throws Exception {
+    test(getFile("window/q3220.sql"), TEST_RES_PATH);
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/288c9522/exec/java-exec/src/test/resources/window/q1.sql
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/q1.sql b/exec/java-exec/src/test/resources/window/q1.sql
new file mode 100644
index 0000000..053b701
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/q1.sql
@@ -0,0 +1,6 @@
+select
+  count(*) over pos_win `count`,
+  sum(salary) over pos_win `sum`
+from
+  dfs_test.`%s/window/%s`
+window pos_win as (partition by position_id)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/drill/blob/288c9522/exec/java-exec/src/test/resources/window/q2.sql
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/q2.sql b/exec/java-exec/src/test/resources/window/q2.sql
new file mode 100644
index 0000000..0e661a7
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/q2.sql
@@ -0,0 +1,10 @@
+select
+  count(*) over pos_win `count`,
+  sum(salary) over pos_win `sum`,
+  row_number() over pos_win `row_number`,
+  rank() over pos_win `rank`,
+  dense_rank() over pos_win `dense_rank`,
+  cume_dist() over pos_win `cume_dist`,
+  percent_rank() over pos_win `percent_rank`
+from dfs_test.`%s/window/%s`
+window pos_win as (partition by position_id order by sub)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/drill/blob/288c9522/exec/java-exec/src/test/resources/window/q3218.sql
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/q3218.sql b/exec/java-exec/src/test/resources/window/q3218.sql
new file mode 100644
index 0000000..45bfd46
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/q3218.sql
@@ -0,0 +1,5 @@
+select
+  max(cast(columns[2] as char(2)))
+    over(partition by cast(columns[2] as char(2))
+         order by cast(columns[0] as int))
+from dfs_test.`%s/window/allData.csv`
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/drill/blob/288c9522/exec/java-exec/src/test/resources/window/q3220.sql
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/q3220.sql b/exec/java-exec/src/test/resources/window/q3220.sql
new file mode 100644
index 0000000..3fdb047
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/q3220.sql
@@ -0,0 +1,3 @@
+select
+  count(1) over(partition by position_id order by sub)
+from dfs_test.`%s/window/b1.p1`
\ No newline at end of file


Mime
View raw message