Merge pull request #1792 from gianm/groupby-hyperunique-postagg-test

GroupByQueryRunnerTest for hyperUnique finalizing post aggregators
This commit is contained in:
Fangjin Yang 2015-10-01 09:07:56 -04:00
commit 4da1575680
1 changed files with 62 additions and 0 deletions

View File

@ -3384,6 +3384,68 @@ public class GroupByQueryRunnerTest
TestHelper.assertExpectedObjects(expectedResults, results, "");
}
@Test
public void testSubqueryWithHyperUniquesPostAggregator()
{
GroupByQuery subquery = GroupByQuery
.builder()
.setDataSource(QueryRunnerTestHelper.dataSource)
.setQuerySegmentSpec(QueryRunnerTestHelper.firstToThird)
.setDimensions(Lists.<DimensionSpec>newArrayList())
.setAggregatorSpecs(
Arrays.asList(
QueryRunnerTestHelper.rowsCount,
new LongSumAggregatorFactory("idx", "index"),
new HyperUniquesAggregatorFactory("quality_uniques_inner", "quality_uniques")
)
)
.setPostAggregatorSpecs(
Arrays.<PostAggregator>asList(
new FieldAccessPostAggregator("quality_uniques_inner_post", "quality_uniques_inner")
)
)
.setGranularity(QueryRunnerTestHelper.dayGran)
.build();
GroupByQuery query = GroupByQuery
.builder()
.setDataSource(subquery)
.setQuerySegmentSpec(QueryRunnerTestHelper.firstToThird)
.setDimensions(Lists.<DimensionSpec>newArrayList())
.setAggregatorSpecs(
Arrays.asList(
new LongSumAggregatorFactory("rows", "rows"),
new LongSumAggregatorFactory("idx", "idx"),
new HyperUniquesAggregatorFactory("quality_uniques_outer", "quality_uniques_inner_post")
)
)
.setPostAggregatorSpecs(
Arrays.<PostAggregator>asList(
new HyperUniqueFinalizingPostAggregator("quality_uniques_outer_post", "quality_uniques_outer")
)
)
.setGranularity(QueryRunnerTestHelper.allGran)
.build();
List<Row> expectedResults = Arrays.asList(
GroupByQueryRunnerTestHelper.createExpectedRow(
"2011-04-01",
"rows",
26L,
"idx",
12446L,
"quality_uniques_outer",
9.019833517963864,
"quality_uniques_outer_post",
9.019833517963864
)
);
// Subqueries are handled by the ToolChest
Iterable<Row> results = GroupByQueryRunnerTestHelper.runQuery(factory, runner, query);
TestHelper.assertExpectedObjects(expectedResults, results, "");
}
@Test
public void testGroupByWithTimeColumn()
{