Repository: drill Updated Branches: refs/heads/master 3cf0514e5 -> 46e3de790
DRILL-4490: Ensure the count generated by ConvertCountToDirectScan is non-nullable Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/46e3de79 Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/46e3de79 Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/46e3de79 Branch: refs/heads/master Commit: 46e3de790da8f9c6d2d18e7e40fd37c01b3b1681 Parents: 3cf0514 Author: Hsuan-Yi Chu <[email protected]> Authored: Wed Mar 9 17:25:11 2016 -0800 Committer: Jinfeng Ni <[email protected]> Committed: Mon Mar 14 10:03:26 2016 -0700 ---------------------------------------------------------------------- .../physical/ConvertCountToDirectScan.java | 2 +- .../exec/fn/impl/TestAggregateFunctions.java | 31 ++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/46e3de79/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/ConvertCountToDirectScan.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/ConvertCountToDirectScan.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/ConvertCountToDirectScan.java index c93978c..879d0f7 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/ConvertCountToDirectScan.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/ConvertCountToDirectScan.java @@ -167,7 +167,7 @@ public class ConvertCountToDirectScan extends Prule { * Class to represent the count aggregate result. */ public static class CountQueryResult { - public Long count; + public long count; public CountQueryResult(long cnt) { this.count = cnt; http://git-wip-us.apache.org/repos/asf/drill/blob/46e3de79/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 43e206e..4d44398 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 @@ -17,12 +17,18 @@ */ package org.apache.drill.exec.fn.impl; +import com.google.common.collect.Lists; +import org.apache.commons.lang3.tuple.Pair; import org.apache.drill.BaseTestQuery; import org.apache.drill.PlanTestBase; +import org.apache.drill.common.expression.SchemaPath; +import org.apache.drill.common.types.TypeProtos; import org.apache.drill.common.util.TestTools; import org.junit.Ignore; import org.junit.Test; +import java.util.List; + public class TestAggregateFunctions extends BaseTestQuery { private static final String TEST_RES_PATH = TestTools.getWorkingPath() + "/src/test/resources"; @@ -460,4 +466,29 @@ public class TestAggregateFunctions extends BaseTestQuery { public void test4443() throws Exception { test("SELECT MIN(columns[1]) FROM dfs_test.`%s/agg/4443.csv` GROUP BY columns[0]", TEST_RES_PATH); } + + @Test + public void testCountStarRequired() throws Exception { + final String query = "select count(*) as col from cp.`tpch/region.parquet`"; + List<Pair<SchemaPath, TypeProtos.MajorType>> expectedSchema = Lists.newArrayList(); + TypeProtos.MajorType majorType = TypeProtos.MajorType.newBuilder() + .setMinorType(TypeProtos.MinorType.BIGINT) + .setMode(TypeProtos.DataMode.REQUIRED) + .build(); + expectedSchema.add(Pair.of(SchemaPath.getSimplePath("col"), majorType)); + + testBuilder() + .sqlQuery(query) + .schemaBaseLine(expectedSchema) + .build() + .run(); + + testBuilder() + .sqlQuery(query) + .unOrdered() + .baselineColumns("col") + .baselineValues(5l) + .build() + .run(); + } }
