Skip to content

Commit

Permalink
DRILL-4490: Ensure the count generated by ConvertCountToDirectScan is…
Browse files Browse the repository at this point in the history
… non-nullable
  • Loading branch information
hsuanyi authored and jinfengni committed Mar 14, 2016
1 parent 3cf0514 commit 46e3de7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Expand Up @@ -167,7 +167,7 @@ public void onMatch(RelOptRuleCall call) {
* Class to represent the count aggregate result.
*/
public static class CountQueryResult {
public Long count;
public long count;

public CountQueryResult(long cnt) {
this.count = cnt;
Expand Down
Expand Up @@ -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";
Expand Down Expand Up @@ -460,4 +466,29 @@ public void testGroupBySystemFuncFileSystemTable() throws Exception {
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();
}
}

0 comments on commit 46e3de7

Please sign in to comment.