DRILL-2013: Fix flatten when no rows match filters
Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/ce0afb1d Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/ce0afb1d Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/ce0afb1d Branch: refs/heads/master Commit: ce0afb1d62b519772084173ed5540cda79a2719b Parents: 1d2ed34 Author: AdamPD <[email protected]> Authored: Fri Jan 23 17:01:36 2015 +1000 Committer: Jason Altekruse <[email protected]> Committed: Thu Feb 26 16:41:03 2015 -0800 ---------------------------------------------------------------------- .../drill/exec/physical/impl/flatten/FlattenRecordBatch.java | 2 +- .../apache/drill/exec/physical/impl/flatten/TestFlatten.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/ce0afb1d/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java index 02c154f..8a87098 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java @@ -152,7 +152,7 @@ public class FlattenRecordBatch extends AbstractSingleRecordBatch<FlattenPOP> { // inside of the the flattener for the current batch setFlattenVector(); - int childCount = flattener.getFlattenField().getAccessor().getValueCount(); + int childCount = incomingRecordCount == 0 ? 0 : flattener.getFlattenField().getAccessor().getValueCount(); int outputRecords = flattener.flattenRecords(0, incomingRecordCount, 0); // TODO - change this to be based on the repeated vector length if (outputRecords < childCount) { http://git-wip-us.apache.org/repos/asf/drill/blob/ce0afb1d/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 b56df84..9518386 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 @@ -241,4 +241,9 @@ public class TestFlatten extends BaseTestQuery { } + @Test + public void testDrill_2013() throws Exception { + test("select flatten(complex), rownum from cp.`/store/json/test_flatten_mappify2.json` where rownum > 5"); + } + }
