Search in sources :

Example 11 with FinalizingFieldAccessPostAggregator

use of org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator 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 12 with FinalizingFieldAccessPostAggregator

use of org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator 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 13 with FinalizingFieldAccessPostAggregator

use of org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator 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 14 with FinalizingFieldAccessPostAggregator

use of org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator 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)

Example 15 with FinalizingFieldAccessPostAggregator

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

the class HllSketchSqlAggregatorTest method testAvgDailyCountDistinctHllSketch.

@Test
public void testAvgDailyCountDistinctHllSketch() throws Exception {
    // Can't vectorize due to outer query, which runs on an inline datasource.
    cannotVectorize();
    final List<Object[]> expectedResults = ImmutableList.of(new Object[] { 1L });
    testQuery("SELECT\n" + "  AVG(u)\n" + "FROM (" + "  SELECT FLOOR(__time TO DAY), APPROX_COUNT_DISTINCT_DS_HLL(cnt) AS u\n" + "  FROM druid.foo\n" + "  GROUP BY 1\n" + ")", ImmutableList.of(GroupByQuery.builder().setDataSource(new QueryDataSource(Druids.newTimeseriesQueryBuilder().dataSource(CalciteTests.DATASOURCE1).intervals(new MultipleIntervalSegmentSpec(ImmutableList.of(Filtration.eternity()))).granularity(new PeriodGranularity(Period.days(1), null, DateTimeZone.UTC)).aggregators(Collections.singletonList(new HllSketchBuildAggregatorFactory("a0:a", "cnt", null, null, ROUND))).postAggregators(ImmutableList.of(new FinalizingFieldAccessPostAggregator("a0", "a0:a"))).context(QUERY_CONTEXT_DEFAULT).build().withOverriddenContext(BaseCalciteQueryTest.getTimeseriesContextWithFloorTime(ImmutableMap.of(TimeseriesQuery.SKIP_EMPTY_BUCKETS, true, BaseQuery.SQL_QUERY_ID, "dummy"), "d0")))).setInterval(new MultipleIntervalSegmentSpec(ImmutableList.of(Filtration.eternity()))).setGranularity(Granularities.ALL).setAggregatorSpecs(NullHandling.replaceWithDefault() ? Arrays.asList(new LongSumAggregatorFactory("_a0:sum", "a0"), new CountAggregatorFactory("_a0:count")) : Arrays.asList(new LongSumAggregatorFactory("_a0:sum", "a0"), new FilteredAggregatorFactory(new CountAggregatorFactory("_a0:count"), BaseCalciteQueryTest.not(BaseCalciteQueryTest.selector("a0", null, null))))).setPostAggregatorSpecs(ImmutableList.of(new ArithmeticPostAggregator("_a0", "quotient", ImmutableList.of(new FieldAccessPostAggregator(null, "_a0:sum"), new FieldAccessPostAggregator(null, "_a0:count"))))).setContext(QUERY_CONTEXT_DEFAULT).build()), expectedResults);
}
Also used : FilteredAggregatorFactory(org.apache.druid.query.aggregation.FilteredAggregatorFactory) ArithmeticPostAggregator(org.apache.druid.query.aggregation.post.ArithmeticPostAggregator) FinalizingFieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator) FieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FieldAccessPostAggregator) QueryDataSource(org.apache.druid.query.QueryDataSource) CountAggregatorFactory(org.apache.druid.query.aggregation.CountAggregatorFactory) PeriodGranularity(org.apache.druid.java.util.common.granularity.PeriodGranularity) LongSumAggregatorFactory(org.apache.druid.query.aggregation.LongSumAggregatorFactory) MultipleIntervalSegmentSpec(org.apache.druid.query.spec.MultipleIntervalSegmentSpec) FinalizingFieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator) HllSketchBuildAggregatorFactory(org.apache.druid.query.aggregation.datasketches.hll.HllSketchBuildAggregatorFactory) BaseCalciteQueryTest(org.apache.druid.sql.calcite.BaseCalciteQueryTest) Test(org.junit.Test)

Aggregations

FinalizingFieldAccessPostAggregator (org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator)22 Test (org.junit.Test)19 FieldAccessPostAggregator (org.apache.druid.query.aggregation.post.FieldAccessPostAggregator)15 TimeseriesQuery (org.apache.druid.query.timeseries.TimeseriesQuery)13 TimeseriesQueryQueryToolChest (org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest)13 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)11 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)5 DoubleSumAggregatorFactory (org.apache.druid.query.aggregation.DoubleSumAggregatorFactory)4 LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)4 DoubleFirstAggregatorFactory (org.apache.druid.query.aggregation.first.DoubleFirstAggregatorFactory)3 FloatFirstAggregatorFactory (org.apache.druid.query.aggregation.first.FloatFirstAggregatorFactory)3 LongFirstAggregatorFactory (org.apache.druid.query.aggregation.first.LongFirstAggregatorFactory)3 StringLastAggregatorFactory (org.apache.druid.query.aggregation.last.StringLastAggregatorFactory)3 ArithmeticPostAggregator (org.apache.druid.query.aggregation.post.ArithmeticPostAggregator)3 MultipleIntervalSegmentSpec (org.apache.druid.query.spec.MultipleIntervalSegmentSpec)3 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)3 Collections (java.util.Collections)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Nullable (javax.annotation.Nullable)2