Search in sources :

Example 1 with PvaluefromZscorePostAggregator

use of org.apache.druid.query.aggregation.teststats.PvaluefromZscorePostAggregator in project druid by druid-io.

the class VarianceGroupByQueryTest method testGroupByTestPvalueZscorePostAgg.

@Test
public void testGroupByTestPvalueZscorePostAgg() {
    // 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, // nonsensical inputs
    new PvaluefromZscorePostAggregator("pvalueZscore", new FieldAccessPostAggregator("f1", "index_stddev")))).setLimitSpec(new DefaultLimitSpec(OrderByColumnSpec.descending("pvalueZscore"), 1)).setGranularity(QueryRunnerTestHelper.DAY_GRAN).build();
    VarianceTestHelper.RowBuilder builder = new VarianceTestHelper.RowBuilder(new String[] { "alias", "rows", "idx", "index_stddev", "index_var", "pvalueZscore" });
    List<ResultRow> expectedResults = builder.add("2011-04-01", "automotive", 1L, 135.0, 0.0, 0.0, 1.0).build(query);
    Iterable<ResultRow> results = GroupByQueryRunnerTestHelper.runQuery(factory, runner, query);
    TestHelper.assertExpectedObjects(expectedResults, results, "groupBy");
}
Also used : ResultRow(org.apache.druid.query.groupby.ResultRow) GroupByQuery(org.apache.druid.query.groupby.GroupByQuery) FieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FieldAccessPostAggregator) DefaultLimitSpec(org.apache.druid.query.groupby.orderby.DefaultLimitSpec) LongSumAggregatorFactory(org.apache.druid.query.aggregation.LongSumAggregatorFactory) PvaluefromZscorePostAggregator(org.apache.druid.query.aggregation.teststats.PvaluefromZscorePostAggregator) DefaultDimensionSpec(org.apache.druid.query.dimension.DefaultDimensionSpec) GroupByQueryRunnerTest(org.apache.druid.query.groupby.GroupByQueryRunnerTest) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Aggregations

LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)1 FieldAccessPostAggregator (org.apache.druid.query.aggregation.post.FieldAccessPostAggregator)1 PvaluefromZscorePostAggregator (org.apache.druid.query.aggregation.teststats.PvaluefromZscorePostAggregator)1 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)1 GroupByQuery (org.apache.druid.query.groupby.GroupByQuery)1 GroupByQueryRunnerTest (org.apache.druid.query.groupby.GroupByQueryRunnerTest)1 ResultRow (org.apache.druid.query.groupby.ResultRow)1 DefaultLimitSpec (org.apache.druid.query.groupby.orderby.DefaultLimitSpec)1 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)1 Test (org.junit.Test)1