Search in sources :

Example 61 with FieldAccessPostAggregator

use of org.apache.druid.query.aggregation.post.FieldAccessPostAggregator in project druid by druid-io.

the class BloomFilterAggregatorFactoryTest method testResultArraySignature.

@Test
public void testResultArraySignature() {
    final TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("dummy").intervals("2000/3000").granularity(Granularities.HOUR).aggregators(new CountAggregatorFactory("count"), new BloomFilterAggregatorFactory("bloom", DefaultDimensionSpec.of("col"), 1024), new BloomFilterMergeAggregatorFactory("bloomMerge", "bloom", 1024)).postAggregators(new FieldAccessPostAggregator("bloom-access", "bloom"), new FinalizingFieldAccessPostAggregator("bloom-finalize", "bloom"), new FieldAccessPostAggregator("bloomMerge-access", "bloomMerge"), new FinalizingFieldAccessPostAggregator("bloomMerge-finalize", "bloomMerge")).build();
    Assert.assertEquals(RowSignature.builder().addTimeColumn().add("count", ColumnType.LONG).add("bloom", BloomFilterAggregatorFactory.TYPE).add("bloomMerge", BloomFilterAggregatorFactory.TYPE).add("bloom-access", BloomFilterAggregatorFactory.TYPE).add("bloom-finalize", BloomFilterAggregatorFactory.TYPE).add("bloomMerge-access", BloomFilterAggregatorFactory.TYPE).add("bloomMerge-finalize", BloomFilterAggregatorFactory.TYPE).build(), new TimeseriesQueryQueryToolChest().resultArraySignature(query));
}
Also used : FinalizingFieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator) FieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FieldAccessPostAggregator) TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) CountAggregatorFactory(org.apache.druid.query.aggregation.CountAggregatorFactory) FinalizingFieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator) TimeseriesQueryQueryToolChest(org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest) Test(org.junit.Test)

Example 62 with FieldAccessPostAggregator

use of org.apache.druid.query.aggregation.post.FieldAccessPostAggregator in project druid by druid-io.

the class ApproximateHistogramAggregatorTest method testResultArraySignature.

@Test
public void testResultArraySignature() {
    final TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("dummy").intervals("2000/3000").granularity(Granularities.HOUR).aggregators(new ApproximateHistogramAggregatorFactory("approxHisto", "col", null, null, null, null, false), new ApproximateHistogramAggregatorFactory("approxHistoBin", "col", null, null, null, null, true)).postAggregators(new FieldAccessPostAggregator("approxHisto-access", "approxHisto"), new FinalizingFieldAccessPostAggregator("approxHisto-finalize", "approxHisto"), new FieldAccessPostAggregator("approxHistoBin-access", "approxHistoBin"), new FinalizingFieldAccessPostAggregator("approxHistoBin-finalize", "approxHistoBin")).build();
    Assert.assertEquals(RowSignature.builder().addTimeColumn().add("approxHisto", null).add("approxHistoBin", ApproximateHistogramAggregatorFactory.TYPE).add("approxHisto-access", ApproximateHistogramAggregatorFactory.TYPE).add("approxHisto-finalize", HistogramAggregatorFactory.TYPE).add("approxHistoBin-access", ApproximateHistogramAggregatorFactory.TYPE).add("approxHistoBin-finalize", ApproximateHistogramAggregatorFactory.TYPE).build(), new TimeseriesQueryQueryToolChest().resultArraySignature(query));
}
Also used : FinalizingFieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator) FieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FieldAccessPostAggregator) TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) FinalizingFieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator) TimeseriesQueryQueryToolChest(org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 63 with FieldAccessPostAggregator

use of org.apache.druid.query.aggregation.post.FieldAccessPostAggregator in project druid by druid-io.

the class FixedBucketsHistogramBufferAggregatorTest method testResultArraySignature.

@Test
public void testResultArraySignature() {
    final TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("dummy").intervals("2000/3000").granularity(Granularities.HOUR).aggregators(new FixedBucketsHistogramAggregatorFactory("fixedHisto", "col", null, 0, 100, null, false), new FixedBucketsHistogramAggregatorFactory("fixedHistoBin", "col", null, 0, 100, null, true)).postAggregators(new FieldAccessPostAggregator("fixedHisto-access", "fixedHisto"), new FinalizingFieldAccessPostAggregator("fixedHisto-finalize", "fixedHisto"), new FieldAccessPostAggregator("fixedHistoBin-access", "fixedHistoBin"), new FinalizingFieldAccessPostAggregator("fixedHistoBin-finalize", "fixedHistoBin")).build();
    Assert.assertEquals(RowSignature.builder().addTimeColumn().add("fixedHisto", null).add("fixedHistoBin", FixedBucketsHistogramAggregator.TYPE).add("fixedHisto-access", FixedBucketsHistogramAggregator.TYPE).add("fixedHisto-finalize", ColumnType.STRING).add("fixedHistoBin-access", FixedBucketsHistogramAggregator.TYPE).add("fixedHistoBin-finalize", FixedBucketsHistogramAggregator.TYPE).build(), new TimeseriesQueryQueryToolChest().resultArraySignature(query));
}
Also used : FinalizingFieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator) FieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FieldAccessPostAggregator) TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) FinalizingFieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator) TimeseriesQueryQueryToolChest(org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest) Test(org.junit.Test)

Example 64 with FieldAccessPostAggregator

use of org.apache.druid.query.aggregation.post.FieldAccessPostAggregator in project druid by druid-io.

the class FixedBucketsHistogramQuantileSqlAggregatorTest method testQuantileOnInnerQuery.

@Test
public void testQuantileOnInnerQuery() throws Exception {
    final List<Object[]> expectedResults;
    if (NullHandling.replaceWithDefault()) {
        expectedResults = ImmutableList.of(new Object[] { 7.0, 11.940000534057617 });
    } else {
        expectedResults = ImmutableList.of(new Object[] { 5.25, 8.920000076293945 });
    }
    testQuery("SELECT AVG(x), APPROX_QUANTILE_FIXED_BUCKETS(x, 0.98, 100, 0.0, 100.0)\n" + "FROM (SELECT dim2, SUM(m1) AS x FROM foo GROUP BY dim2)", ImmutableList.of(GroupByQuery.builder().setDataSource(new QueryDataSource(GroupByQuery.builder().setDataSource(CalciteTests.DATASOURCE1).setInterval(new MultipleIntervalSegmentSpec(ImmutableList.of(Filtration.eternity()))).setGranularity(Granularities.ALL).setDimensions(new DefaultDimensionSpec("dim2", "d0")).setAggregatorSpecs(ImmutableList.of(new DoubleSumAggregatorFactory("a0", "m1"))).setContext(QUERY_CONTEXT_DEFAULT).build())).setInterval(new MultipleIntervalSegmentSpec(ImmutableList.of(Filtration.eternity()))).setGranularity(Granularities.ALL).setAggregatorSpecs(new DoubleSumAggregatorFactory("_a0:sum", "a0"), new CountAggregatorFactory("_a0:count"), new FixedBucketsHistogramAggregatorFactory("_a1:agg", "a0", 100, 0, 100.0d, FixedBucketsHistogram.OutlierHandlingMode.IGNORE, false)).setPostAggregatorSpecs(ImmutableList.of(new ArithmeticPostAggregator("_a0", "quotient", ImmutableList.of(new FieldAccessPostAggregator(null, "_a0:sum"), new FieldAccessPostAggregator(null, "_a0:count"))), new QuantilePostAggregator("_a1", "_a1:agg", 0.98f))).setContext(QUERY_CONTEXT_DEFAULT).build()), expectedResults);
}
Also used : ArithmeticPostAggregator(org.apache.druid.query.aggregation.post.ArithmeticPostAggregator) FieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FieldAccessPostAggregator) QueryDataSource(org.apache.druid.query.QueryDataSource) DoubleSumAggregatorFactory(org.apache.druid.query.aggregation.DoubleSumAggregatorFactory) CountAggregatorFactory(org.apache.druid.query.aggregation.CountAggregatorFactory) QuantilePostAggregator(org.apache.druid.query.aggregation.histogram.QuantilePostAggregator) MultipleIntervalSegmentSpec(org.apache.druid.query.spec.MultipleIntervalSegmentSpec) DefaultDimensionSpec(org.apache.druid.query.dimension.DefaultDimensionSpec) FixedBucketsHistogramAggregatorFactory(org.apache.druid.query.aggregation.histogram.FixedBucketsHistogramAggregatorFactory) BaseCalciteQueryTest(org.apache.druid.sql.calcite.BaseCalciteQueryTest) Test(org.junit.Test)

Example 65 with FieldAccessPostAggregator

use of org.apache.druid.query.aggregation.post.FieldAccessPostAggregator in project druid by druid-io.

the class TimestampMinMaxAggregatorFactoryTest method testResultArraySignature.

@Test
public void testResultArraySignature() {
    final TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("dummy").intervals("2000/3000").granularity(Granularities.HOUR).aggregators(new CountAggregatorFactory("count"), new TimestampMaxAggregatorFactory("timeMax", "__time", null), new TimestampMinAggregatorFactory("timeMin", "__time", null)).postAggregators(new FieldAccessPostAggregator("timeMax-access", "timeMax"), new FinalizingFieldAccessPostAggregator("timeMax-finalize", "timeMax"), new FieldAccessPostAggregator("timeMin-access", "timeMin"), new FinalizingFieldAccessPostAggregator("timeMin-finalize", "timeMin")).build();
    Assert.assertEquals(RowSignature.builder().addTimeColumn().add("count", ColumnType.LONG).add("timeMax", null).add("timeMin", null).add("timeMax-access", ColumnType.LONG).add("timeMax-finalize", TimestampAggregatorFactory.FINALIZED_TYPE).add("timeMin-access", ColumnType.LONG).add("timeMin-finalize", TimestampAggregatorFactory.FINALIZED_TYPE).build(), new TimeseriesQueryQueryToolChest().resultArraySignature(query));
}
Also used : FinalizingFieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator) FieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FieldAccessPostAggregator) TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) FinalizingFieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator) TimeseriesQueryQueryToolChest(org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest) Test(org.junit.Test)

Aggregations

FieldAccessPostAggregator (org.apache.druid.query.aggregation.post.FieldAccessPostAggregator)108 Test (org.junit.Test)97 PostAggregator (org.apache.druid.query.aggregation.PostAggregator)45 ArithmeticPostAggregator (org.apache.druid.query.aggregation.post.ArithmeticPostAggregator)32 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)30 FinalizingFieldAccessPostAggregator (org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator)24 LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)22 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)22 TimeseriesQuery (org.apache.druid.query.timeseries.TimeseriesQuery)17 TimeseriesQueryQueryToolChest (org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest)17 ConstantPostAggregator (org.apache.druid.query.aggregation.post.ConstantPostAggregator)15 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)15 MultipleIntervalSegmentSpec (org.apache.druid.query.spec.MultipleIntervalSegmentSpec)14 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)12 HashMap (java.util.HashMap)11 DoubleSumAggregatorFactory (org.apache.druid.query.aggregation.DoubleSumAggregatorFactory)11 QueryDataSource (org.apache.druid.query.QueryDataSource)10 Aggregator (org.apache.druid.query.aggregation.Aggregator)10 AggregatorFactory (org.apache.druid.query.aggregation.AggregatorFactory)10 BaseCalciteQueryTest (org.apache.druid.sql.calcite.BaseCalciteQueryTest)10