Search in sources :

Example 6 with FinalizingFieldAccessPostAggregator

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

the class TDigestSketchAggregatorFactoryTest method testResultArraySignature.

@Test
public void testResultArraySignature() {
    final TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("dummy").intervals("2000/3000").granularity(Granularities.HOUR).aggregators(new CountAggregatorFactory("count"), new TDigestSketchAggregatorFactory("tdigest", "col", null)).postAggregators(new FieldAccessPostAggregator("tdigest-access", "tdigest"), new FinalizingFieldAccessPostAggregator("tdigest-finalize", "tdigest")).build();
    Assert.assertEquals(RowSignature.builder().addTimeColumn().add("count", ColumnType.LONG).add("tdigest", TDigestSketchAggregatorFactory.TYPE).add("tdigest-access", TDigestSketchAggregatorFactory.TYPE).add("tdigest-finalize", TDigestSketchAggregatorFactory.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 7 with FinalizingFieldAccessPostAggregator

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

the class SketchAggregatorFactoryTest method testResultArraySignature.

@Test
public void testResultArraySignature() {
    final TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("dummy").intervals("2000/3000").granularity(Granularities.HOUR).aggregators(new CountAggregatorFactory("count"), new OldSketchBuildAggregatorFactory("oldBuild", "col", 16), new OldSketchMergeAggregatorFactory("oldMerge", "col", 16, false), new OldSketchMergeAggregatorFactory("oldMergeFinalize", "col", 16, true), new SketchMergeAggregatorFactory("merge", "col", 16, false, false, null), new SketchMergeAggregatorFactory("mergeFinalize", "col", 16, true, false, null)).postAggregators(new FieldAccessPostAggregator("oldBuild-access", "oldBuild"), new FinalizingFieldAccessPostAggregator("oldBuild-finalize", "oldBuild"), new FieldAccessPostAggregator("oldMerge-access", "oldMerge"), new FinalizingFieldAccessPostAggregator("oldMerge-finalize", "oldMerge"), new FieldAccessPostAggregator("oldMergeFinalize-access", "oldMergeFinalize"), new FinalizingFieldAccessPostAggregator("oldMergeFinalize-finalize", "oldMergeFinalize"), new FieldAccessPostAggregator("merge-access", "merge"), new FinalizingFieldAccessPostAggregator("merge-finalize", "merge"), new FieldAccessPostAggregator("mergeFinalize-access", "mergeFinalize"), new FinalizingFieldAccessPostAggregator("mergeFinalize-finalize", "mergeFinalize"), new SketchEstimatePostAggregator("sketchEstimate", new FieldAccessPostAggregator(null, "merge"), null), new SketchEstimatePostAggregator("sketchEstimateStdDev", new FieldAccessPostAggregator(null, "merge"), 2), new SketchSetPostAggregator("sketchSet", "UNION", null, ImmutableList.of(new FieldAccessPostAggregator(null, "oldMerge"), new FieldAccessPostAggregator(null, "merge"))), new SketchToStringPostAggregator("sketchString", new FieldAccessPostAggregator(null, "merge"))).build();
    Assert.assertEquals(RowSignature.builder().addTimeColumn().add("count", ColumnType.LONG).add("oldBuild", null).add("oldMerge", SketchModule.MERGE_TYPE).add("oldMergeFinalize", null).add("merge", SketchModule.BUILD_TYPE).add("mergeFinalize", null).add("oldBuild-access", SketchModule.BUILD_TYPE).add("oldBuild-finalize", ColumnType.DOUBLE).add("oldMerge-access", SketchModule.MERGE_TYPE).add("oldMerge-finalize", SketchModule.MERGE_TYPE).add("oldMergeFinalize-access", SketchModule.MERGE_TYPE).add("oldMergeFinalize-finalize", ColumnType.DOUBLE).add("merge-access", SketchModule.BUILD_TYPE).add("merge-finalize", SketchModule.BUILD_TYPE).add("mergeFinalize-access", SketchModule.BUILD_TYPE).add("mergeFinalize-finalize", ColumnType.DOUBLE).add("sketchEstimate", ColumnType.DOUBLE).add("sketchEstimateStdDev", SketchModule.MERGE_TYPE).add("sketchSet", SketchModule.MERGE_TYPE).add("sketchString", ColumnType.STRING).build(), new TimeseriesQueryQueryToolChest().resultArraySignature(query));
}
Also used : OldSketchMergeAggregatorFactory(org.apache.druid.query.aggregation.datasketches.theta.oldapi.OldSketchMergeAggregatorFactory) 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) OldSketchMergeAggregatorFactory(org.apache.druid.query.aggregation.datasketches.theta.oldapi.OldSketchMergeAggregatorFactory) FinalizingFieldAccessPostAggregator(org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator) TimeseriesQueryQueryToolChest(org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest) OldSketchBuildAggregatorFactory(org.apache.druid.query.aggregation.datasketches.theta.oldapi.OldSketchBuildAggregatorFactory) Test(org.junit.Test)

Example 8 with FinalizingFieldAccessPostAggregator

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

the class DoublesSketchAggregatorFactoryTest method testResultArraySignature.

@Test
public void testResultArraySignature() {
    final TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("dummy").intervals("2000/3000").granularity(Granularities.HOUR).aggregators(new CountAggregatorFactory("count"), new DoublesSketchAggregatorFactory("doublesSketch", "col", 8), new DoublesSketchMergeAggregatorFactory("doublesSketchMerge", 8)).postAggregators(new FieldAccessPostAggregator("doublesSketch-access", "doublesSketch"), new FinalizingFieldAccessPostAggregator("doublesSketch-finalize", "doublesSketch"), new FieldAccessPostAggregator("doublesSketchMerge-access", "doublesSketchMerge"), new FinalizingFieldAccessPostAggregator("doublesSketchMerge-finalize", "doublesSketchMerge")).build();
    Assert.assertEquals(RowSignature.builder().addTimeColumn().add("count", ColumnType.LONG).add("doublesSketch", null).add("doublesSketchMerge", null).add("doublesSketch-access", DoublesSketchModule.TYPE).add("doublesSketch-finalize", ColumnType.LONG).add("doublesSketchMerge-access", DoublesSketchModule.TYPE).add("doublesSketchMerge-finalize", ColumnType.LONG).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 9 with FinalizingFieldAccessPostAggregator

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

the class HllSketchAggregatorFactoryTest method testResultArraySignature.

@Test
public void testResultArraySignature() {
    final TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("dummy").intervals("2000/3000").granularity(Granularities.HOUR).aggregators(new CountAggregatorFactory("count"), new HllSketchBuildAggregatorFactory("hllBuild", "col", null, null, false), new HllSketchBuildAggregatorFactory("hllBuildRound", "col", null, null, true), new HllSketchMergeAggregatorFactory("hllMerge", "col", null, null, false), new HllSketchMergeAggregatorFactory("hllMergeRound", "col", null, null, true)).postAggregators(new FieldAccessPostAggregator("hllBuild-access", "hllBuild"), new FinalizingFieldAccessPostAggregator("hllBuild-finalize", "hllBuild"), new FieldAccessPostAggregator("hllBuildRound-access", "hllBuildRound"), new FinalizingFieldAccessPostAggregator("hllBuildRound-finalize", "hllBuildRound"), new FieldAccessPostAggregator("hllMerge-access", "hllMerge"), new FinalizingFieldAccessPostAggregator("hllMerge-finalize", "hllMerge"), new FieldAccessPostAggregator("hllMergeRound-access", "hllMergeRound"), new FinalizingFieldAccessPostAggregator("hllMergeRound-finalize", "hllMergeRound")).build();
    Assert.assertEquals(RowSignature.builder().addTimeColumn().add("count", ColumnType.LONG).add("hllBuild", null).add("hllBuildRound", null).add("hllMerge", null).add("hllMergeRound", null).add("hllBuild-access", HllSketchBuildAggregatorFactory.TYPE).add("hllBuild-finalize", ColumnType.DOUBLE).add("hllBuildRound-access", HllSketchBuildAggregatorFactory.TYPE).add("hllBuildRound-finalize", ColumnType.LONG).add("hllMerge-access", HllSketchMergeAggregatorFactory.TYPE).add("hllMerge-finalize", ColumnType.DOUBLE).add("hllMergeRound-access", HllSketchMergeAggregatorFactory.TYPE).add("hllMergeRound-finalize", ColumnType.LONG).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 10 with FinalizingFieldAccessPostAggregator

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

the class ThetaSketchSqlAggregatorTest method testAvgDailyCountDistinctThetaSketch.

@Test
public void testAvgDailyCountDistinctThetaSketch() throws Exception {
    // Can't vectorize due to outer query (it operates on an inlined data source, which cannot be vectorized).
    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_THETA(cnt) AS u FROM druid.foo GROUP BY 1)", 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 SketchMergeAggregatorFactory("a0:a", "cnt", null, null, null, null))).postAggregators(ImmutableList.of(new FinalizingFieldAccessPostAggregator("a0", "a0:a"))).context(TIMESERIES_CONTEXT_BY_GRAN).build().withOverriddenContext(BaseCalciteQueryTest.getTimeseriesContextWithFloorTime(TIMESERIES_CONTEXT_BY_GRAN, "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) SketchMergeAggregatorFactory(org.apache.druid.query.aggregation.datasketches.theta.SketchMergeAggregatorFactory) 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) 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