From 774765dc40af17ffe79a84cd4e94d5b0aaff5659 Mon Sep 17 00:00:00 2001 From: Gian Merlino Date: Thu, 1 Oct 2015 00:09:29 -0400 Subject: [PATCH] GroupByQueryRunnerTest for hyperUnique finalizing post aggregators --- .../query/groupby/GroupByQueryRunnerTest.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/processing/src/test/java/io/druid/query/groupby/GroupByQueryRunnerTest.java b/processing/src/test/java/io/druid/query/groupby/GroupByQueryRunnerTest.java index ae22708742f..bacd6a1a31d 100644 --- a/processing/src/test/java/io/druid/query/groupby/GroupByQueryRunnerTest.java +++ b/processing/src/test/java/io/druid/query/groupby/GroupByQueryRunnerTest.java @@ -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.newArrayList()) + .setAggregatorSpecs( + Arrays.asList( + QueryRunnerTestHelper.rowsCount, + new LongSumAggregatorFactory("idx", "index"), + new HyperUniquesAggregatorFactory("quality_uniques_inner", "quality_uniques") + ) + ) + .setPostAggregatorSpecs( + Arrays.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.newArrayList()) + .setAggregatorSpecs( + Arrays.asList( + new LongSumAggregatorFactory("rows", "rows"), + new LongSumAggregatorFactory("idx", "idx"), + new HyperUniquesAggregatorFactory("quality_uniques_outer", "quality_uniques_inner_post") + ) + ) + .setPostAggregatorSpecs( + Arrays.asList( + new HyperUniqueFinalizingPostAggregator("quality_uniques_outer_post", "quality_uniques_outer") + ) + ) + .setGranularity(QueryRunnerTestHelper.allGran) + .build(); + + List 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 results = GroupByQueryRunnerTestHelper.runQuery(factory, runner, query); + TestHelper.assertExpectedObjects(expectedResults, results, ""); + } + @Test public void testGroupByWithTimeColumn() {