drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacq...@apache.org
Subject [6/8] drill git commit: DRILL-3069: Fix StreamingAggBatch to appropriately set current index when it receives empty batches
Date Thu, 14 May 2015 04:42:11 GMT
DRILL-3069: Fix StreamingAggBatch to appropriately set current index when it receives empty
batches


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

Branch: refs/heads/master
Commit: 97a63168e93a70c7ed88d2e801dd2ea2e5f1dd74
Parents: b1b75f6
Author: Mehant Baid <mehantr@gmail.com>
Authored: Wed May 13 17:17:35 2015 -0700
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Wed May 13 19:34:01 2015 -0700

----------------------------------------------------------------------
 .../impl/aggregate/StreamingAggTemplate.java    |  1 +
 .../exec/fn/impl/TestAggregateFunctions.java    | 34 ++++++++++++++++++++
 .../test/resources/agg/bugs/drill3069/1.json    |  2 ++
 .../test/resources/agg/bugs/drill3069/2.json    |  2 ++
 .../test/resources/agg/bugs/drill3069/3.json    |  2 ++
 5 files changed, 41 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/97a63168/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/StreamingAggTemplate.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/StreamingAggTemplate.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/StreamingAggTemplate.java
index 0bbfd18..4932b0f 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/StreamingAggTemplate.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/StreamingAggTemplate.java
@@ -95,6 +95,7 @@ public abstract class StreamingAggTemplate implements StreamingAggregator
{
               if (incoming.getRecordCount() == 0) {
                 continue;
               } else {
+                currentIndex = this.getVectorIndex(underlyingIndex);
                 break outer;
               }
             case OUT_OF_MEMORY:

http://git-wip-us.apache.org/repos/asf/drill/blob/97a63168/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java
index 69a7cbf..78ebe0f 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java
@@ -19,11 +19,14 @@ package org.apache.drill.exec.fn.impl;
 
 import org.apache.drill.BaseTestQuery;
 import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.common.util.TestTools;
 import org.junit.Ignore;
 import org.junit.Test;
 
 public class TestAggregateFunctions extends BaseTestQuery {
 
+  private static final String TEST_RES_PATH =   TestTools.getWorkingPath() + "/src/test/resources";
+
   /*
    * Test checks the count of a nullable column within a map
    * and verifies count is equal only to the number of times the
@@ -289,4 +292,35 @@ public class TestAggregateFunctions extends BaseTestQuery {
         .go();
 
   }
+
+  /*
+   * Streaming agg on top of a filter produces wrong results if the first two batches are
filtered out.
+   * In the below test we have three files in the input directory and since the ordering
of reading
+   * of these files may not be deterministic, we have three tests to make sure we test the
case where
+   * streaming agg gets two empty batches.
+   */
+  @Test
+  public void drill3069() throws Exception {
+    final String query = "select max(foo) col1 from dfs_test.`%s/agg/bugs/drill3069` where
foo = %d";
+    testBuilder()
+        .sqlQuery(String.format(query, TEST_RES_PATH, 2))
+        .unOrdered()
+        .baselineColumns("col1")
+        .baselineValues(2l)
+        .go();
+
+    testBuilder()
+        .sqlQuery(String.format(query, TEST_RES_PATH, 4))
+        .unOrdered()
+        .baselineColumns("col1")
+        .baselineValues(4l)
+        .go();
+
+    testBuilder()
+        .sqlQuery(String.format(query, TEST_RES_PATH, 6))
+        .unOrdered()
+        .baselineColumns("col1")
+        .baselineValues(6l)
+        .go();
+  }
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/97a63168/exec/java-exec/src/test/resources/agg/bugs/drill3069/1.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/agg/bugs/drill3069/1.json b/exec/java-exec/src/test/resources/agg/bugs/drill3069/1.json
new file mode 100644
index 0000000..9bf33e6
--- /dev/null
+++ b/exec/java-exec/src/test/resources/agg/bugs/drill3069/1.json
@@ -0,0 +1,2 @@
+{"foo": 1}
+{"foo": 2}

http://git-wip-us.apache.org/repos/asf/drill/blob/97a63168/exec/java-exec/src/test/resources/agg/bugs/drill3069/2.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/agg/bugs/drill3069/2.json b/exec/java-exec/src/test/resources/agg/bugs/drill3069/2.json
new file mode 100644
index 0000000..b5e059c
--- /dev/null
+++ b/exec/java-exec/src/test/resources/agg/bugs/drill3069/2.json
@@ -0,0 +1,2 @@
+{"foo": 3}
+{"foo": 4}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/drill/blob/97a63168/exec/java-exec/src/test/resources/agg/bugs/drill3069/3.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/agg/bugs/drill3069/3.json b/exec/java-exec/src/test/resources/agg/bugs/drill3069/3.json
new file mode 100644
index 0000000..ac7915d
--- /dev/null
+++ b/exec/java-exec/src/test/resources/agg/bugs/drill3069/3.json
@@ -0,0 +1,2 @@
+{"foo": 5}
+{"foo": 6}
\ No newline at end of file


Mime
View raw message