use of org.apache.druid.query.aggregation.post.ConstantPostAggregator in project druid by druid-io.
the class VarianceGroupByQueryTest method testGroupByZtestPostAgg.
@Test
public void testGroupByZtestPostAgg() {
// test postaggs from 'teststats' package in here since we've already gone to the trouble of setting up the test
GroupByQuery query = queryBuilder.setDataSource(QueryRunnerTestHelper.DATA_SOURCE).setQuerySegmentSpec(QueryRunnerTestHelper.FIRST_TO_THIRD).setDimensions(new DefaultDimensionSpec("quality", "alias")).setAggregatorSpecs(QueryRunnerTestHelper.ROWS_COUNT, VarianceTestHelper.INDEX_VARIANCE_AGGR, new LongSumAggregatorFactory("idx", "index")).setPostAggregatorSpecs(ImmutableList.of(VarianceTestHelper.STD_DEV_OF_INDEX_POST_AGGR, // these inputs are totally nonsensical, i just want the code path to be executed
new ZtestPostAggregator("ztest", new FieldAccessPostAggregator("f1", "idx"), new ConstantPostAggregator("f2", 100000L), new FieldAccessPostAggregator("f3", "index_stddev"), new ConstantPostAggregator("f2", 100000L)))).setLimitSpec(new DefaultLimitSpec(OrderByColumnSpec.descending("ztest"), 1)).setGranularity(QueryRunnerTestHelper.DAY_GRAN).build();
VarianceTestHelper.RowBuilder builder = new VarianceTestHelper.RowBuilder(new String[] { "alias", "rows", "idx", "index_stddev", "index_var", "ztest" });
List<ResultRow> expectedResults = builder.add("2011-04-01", "premium", 3L, 2900.0, 726.632270328514, 527994.4562827706, 36.54266309285626).build(query);
Iterable<ResultRow> results = GroupByQueryRunnerTestHelper.runQuery(factory, runner, query);
TestHelper.assertExpectedObjects(expectedResults, results, "groupBy");
}
use of org.apache.druid.query.aggregation.post.ConstantPostAggregator in project druid by druid-io.
the class ArrayOfDoublesSketchToQuantilesSketchPostAggregatorTest method testToString.
@Test
public void testToString() {
PostAggregator postAgg = new ArrayOfDoublesSketchToQuantilesSketchPostAggregator("a", new ConstantPostAggregator("", 0), 2, 16);
Assert.assertEquals("ArrayOfDoublesSketchToQuantilesSketchPostAggregator{name='a', field=ConstantPostAggregator{name='', constantValue=0}, column=2, k=16}", postAgg.toString());
}
use of org.apache.druid.query.aggregation.post.ConstantPostAggregator in project druid by druid-io.
the class ArrayOfDoublesSketchToVariancesPostAggregatorTest method testResultArraySignature.
@Test
public void testResultArraySignature() {
final TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("dummy").intervals("2000/3000").granularity(Granularities.HOUR).aggregators(new CountAggregatorFactory("count")).postAggregators(new ArrayOfDoublesSketchToVariancesPostAggregator("a", new ConstantPostAggregator("", 0))).build();
Assert.assertEquals(RowSignature.builder().addTimeColumn().add("count", ColumnType.LONG).add("a", ColumnType.DOUBLE_ARRAY).build(), new TimeseriesQueryQueryToolChest().resultArraySignature(query));
}
use of org.apache.druid.query.aggregation.post.ConstantPostAggregator in project druid by druid-io.
the class ArrayOfDoublesSketchToStringPostAggregatorTest method testComparator.
@Test
public void testComparator() {
expectedException.expect(IAE.class);
expectedException.expectMessage("Comparing sketch summaries is not supported");
final PostAggregator postAgg = new ArrayOfDoublesSketchToStringPostAggregator("a", new ConstantPostAggregator("", 0));
postAgg.getComparator();
}
use of org.apache.druid.query.aggregation.post.ConstantPostAggregator in project druid by druid-io.
the class ArrayOfDoublesSketchToStringPostAggregatorTest method testSerde.
@Test
public void testSerde() throws JsonProcessingException {
final PostAggregator there = new ArrayOfDoublesSketchToStringPostAggregator("a", new ConstantPostAggregator("", 0));
DefaultObjectMapper mapper = new DefaultObjectMapper();
ArrayOfDoublesSketchToStringPostAggregator andBackAgain = mapper.readValue(mapper.writeValueAsString(there), ArrayOfDoublesSketchToStringPostAggregator.class);
Assert.assertEquals(there, andBackAgain);
Assert.assertArrayEquals(there.getCacheKey(), andBackAgain.getCacheKey());
}
Aggregations