Search in sources :

Example 6 with HavingSpec

use of io.druid.query.groupby.having.HavingSpec in project druid by druid-io.

the class GroupByQueryRunnerTest method testHavingSpec.

@Test
public void testHavingSpec() {
    List<Row> expectedResults = Arrays.asList(GroupByQueryRunnerTestHelper.createExpectedRow("2011-04-01", "alias", "business", "rows", 2L, "idx", 217L), GroupByQueryRunnerTestHelper.createExpectedRow("2011-04-01", "alias", "mezzanine", "rows", 6L, "idx", 4420L), GroupByQueryRunnerTestHelper.createExpectedRow("2011-04-01", "alias", "premium", "rows", 6L, "idx", 4416L));
    GroupByQuery.Builder builder = GroupByQuery.builder().setDataSource(QueryRunnerTestHelper.dataSource).setInterval("2011-04-02/2011-04-04").setDimensions(Lists.<DimensionSpec>newArrayList(new DefaultDimensionSpec("quality", "alias"))).setAggregatorSpecs(Arrays.asList(QueryRunnerTestHelper.rowsCount, new LongSumAggregatorFactory("idx", "index"))).setGranularity(new PeriodGranularity(new Period("P1M"), null, null)).setHavingSpec(new OrHavingSpec(ImmutableList.<HavingSpec>of(new GreaterThanHavingSpec("rows", 2L), new EqualToHavingSpec("idx", 217L))));
    final GroupByQuery fullQuery = builder.build();
    TestHelper.assertExpectedObjects(expectedResults, GroupByQueryRunnerTestHelper.runQuery(factory, runner, fullQuery), "");
}
Also used : DefaultDimensionSpec(io.druid.query.dimension.DefaultDimensionSpec) RegexFilteredDimensionSpec(io.druid.query.dimension.RegexFilteredDimensionSpec) ExtractionDimensionSpec(io.druid.query.dimension.ExtractionDimensionSpec) ListFilteredDimensionSpec(io.druid.query.dimension.ListFilteredDimensionSpec) DimensionSpec(io.druid.query.dimension.DimensionSpec) EqualToHavingSpec(io.druid.query.groupby.having.EqualToHavingSpec) OrHavingSpec(io.druid.query.groupby.having.OrHavingSpec) LongSumAggregatorFactory(io.druid.query.aggregation.LongSumAggregatorFactory) PeriodGranularity(io.druid.java.util.common.granularity.PeriodGranularity) Period(org.joda.time.Period) DefaultDimensionSpec(io.druid.query.dimension.DefaultDimensionSpec) GreaterThanHavingSpec(io.druid.query.groupby.having.GreaterThanHavingSpec) HavingSpec(io.druid.query.groupby.having.HavingSpec) DimFilterHavingSpec(io.druid.query.groupby.having.DimFilterHavingSpec) BaseHavingSpec(io.druid.query.groupby.having.BaseHavingSpec) OrHavingSpec(io.druid.query.groupby.having.OrHavingSpec) DimensionSelectorHavingSpec(io.druid.query.groupby.having.DimensionSelectorHavingSpec) EqualToHavingSpec(io.druid.query.groupby.having.EqualToHavingSpec) GreaterThanHavingSpec(io.druid.query.groupby.having.GreaterThanHavingSpec) Row(io.druid.data.input.Row) Test(org.junit.Test)

Aggregations

LongSumAggregatorFactory (io.druid.query.aggregation.LongSumAggregatorFactory)6 DefaultDimensionSpec (io.druid.query.dimension.DefaultDimensionSpec)6 BaseHavingSpec (io.druid.query.groupby.having.BaseHavingSpec)6 DimFilterHavingSpec (io.druid.query.groupby.having.DimFilterHavingSpec)6 DimensionSelectorHavingSpec (io.druid.query.groupby.having.DimensionSelectorHavingSpec)6 EqualToHavingSpec (io.druid.query.groupby.having.EqualToHavingSpec)6 GreaterThanHavingSpec (io.druid.query.groupby.having.GreaterThanHavingSpec)6 HavingSpec (io.druid.query.groupby.having.HavingSpec)6 OrHavingSpec (io.druid.query.groupby.having.OrHavingSpec)6 Test (org.junit.Test)6 Row (io.druid.data.input.Row)5 PeriodGranularity (io.druid.java.util.common.granularity.PeriodGranularity)5 Period (org.joda.time.Period)5 MergeSequence (io.druid.java.util.common.guava.MergeSequence)3 Sequence (io.druid.java.util.common.guava.Sequence)3 FinalizeResultsQueryRunner (io.druid.query.FinalizeResultsQueryRunner)3 Query (io.druid.query.Query)3 QueryRunner (io.druid.query.QueryRunner)3 DimensionSpec (io.druid.query.dimension.DimensionSpec)3 ExtractionDimensionSpec (io.druid.query.dimension.ExtractionDimensionSpec)3