Search in sources :

Example 11 with TDigestSketchAggregatorFactory

use of org.apache.druid.query.aggregation.tdigestsketch.TDigestSketchAggregatorFactory in project druid by druid-io.

the class TDigestSketchSqlAggregatorTest method testCompressionParamForTDigestQuantileAgg.

@Test
public void testCompressionParamForTDigestQuantileAgg() throws Exception {
    cannotVectorize();
    testQuery("SELECT\n" + "TDIGEST_QUANTILE(m1, 0.0), TDIGEST_QUANTILE(m1, 0.5, 200), TDIGEST_QUANTILE(m1, 1.0, 300)\n" + "FROM foo", ImmutableList.of(Druids.newTimeseriesQueryBuilder().dataSource(CalciteTests.DATASOURCE1).intervals(new MultipleIntervalSegmentSpec(ImmutableList.of(Filtration.eternity()))).granularity(Granularities.ALL).aggregators(ImmutableList.of(new TDigestSketchAggregatorFactory("a0:agg", "m1", TDigestSketchAggregatorFactory.DEFAULT_COMPRESSION), new TDigestSketchAggregatorFactory("a1:agg", "m1", 200), new TDigestSketchAggregatorFactory("a2:agg", "m1", 300))).postAggregators(new TDigestSketchToQuantilePostAggregator("a0", makeFieldAccessPostAgg("a0:agg"), 0.0f), new TDigestSketchToQuantilePostAggregator("a1", makeFieldAccessPostAgg("a1:agg"), 0.5f), new TDigestSketchToQuantilePostAggregator("a2", makeFieldAccessPostAgg("a2:agg"), 1.0f)).context(QUERY_CONTEXT_DEFAULT).build()), ImmutableList.of(new Object[] { 1.0, 3.5, 6.0 }));
}
Also used : TDigestSketchAggregatorFactory(org.apache.druid.query.aggregation.tdigestsketch.TDigestSketchAggregatorFactory) TDigestSketchToQuantilePostAggregator(org.apache.druid.query.aggregation.tdigestsketch.TDigestSketchToQuantilePostAggregator) MultipleIntervalSegmentSpec(org.apache.druid.query.spec.MultipleIntervalSegmentSpec) BaseCalciteQueryTest(org.apache.druid.sql.calcite.BaseCalciteQueryTest) Test(org.junit.Test)

Example 12 with TDigestSketchAggregatorFactory

use of org.apache.druid.query.aggregation.tdigestsketch.TDigestSketchAggregatorFactory in project druid by druid-io.

the class TDigestSketchSqlAggregatorTest method testEmptyTimeseriesResults.

@Test
public void testEmptyTimeseriesResults() throws Exception {
    cannotVectorize();
    testQuery("SELECT\n" + "TDIGEST_GENERATE_SKETCH(m1)," + "TDIGEST_QUANTILE(qsketch_m1, 0.1)" + "FROM foo WHERE dim2 = 0", ImmutableList.of(Druids.newTimeseriesQueryBuilder().dataSource(CalciteTests.DATASOURCE1).intervals(new MultipleIntervalSegmentSpec(ImmutableList.of(Filtration.eternity()))).filters(bound("dim2", "0", "0", false, false, null, StringComparators.NUMERIC)).granularity(Granularities.ALL).aggregators(ImmutableList.of(new TDigestSketchAggregatorFactory("a0:agg", "m1", TDigestSketchAggregatorFactory.DEFAULT_COMPRESSION), new TDigestSketchAggregatorFactory("a1:agg", "qsketch_m1", 100))).postAggregators(new TDigestSketchToQuantilePostAggregator("a1", makeFieldAccessPostAgg("a1:agg"), 0.1f)).context(QUERY_CONTEXT_DEFAULT).build()), ImmutableList.of(new Object[] { "\"AAAAAX/wAAAAAAAA//AAAAAAAABAWQAAAAAAAAAAAAA=\"", Double.NaN }));
}
Also used : TDigestSketchAggregatorFactory(org.apache.druid.query.aggregation.tdigestsketch.TDigestSketchAggregatorFactory) TDigestSketchToQuantilePostAggregator(org.apache.druid.query.aggregation.tdigestsketch.TDigestSketchToQuantilePostAggregator) MultipleIntervalSegmentSpec(org.apache.druid.query.spec.MultipleIntervalSegmentSpec) BaseCalciteQueryTest(org.apache.druid.sql.calcite.BaseCalciteQueryTest) Test(org.junit.Test)

Aggregations

TDigestSketchAggregatorFactory (org.apache.druid.query.aggregation.tdigestsketch.TDigestSketchAggregatorFactory)12 BaseCalciteQueryTest (org.apache.druid.sql.calcite.BaseCalciteQueryTest)9 Test (org.junit.Test)9 TDigestSketchToQuantilePostAggregator (org.apache.druid.query.aggregation.tdigestsketch.TDigestSketchToQuantilePostAggregator)8 MultipleIntervalSegmentSpec (org.apache.druid.query.spec.MultipleIntervalSegmentSpec)7 Nullable (javax.annotation.Nullable)2 RexNode (org.apache.calcite.rex.RexNode)2 AggregatorFactory (org.apache.druid.query.aggregation.AggregatorFactory)2 FieldAccessPostAggregator (org.apache.druid.query.aggregation.post.FieldAccessPostAggregator)2 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)2 Aggregation (org.apache.druid.sql.calcite.aggregation.Aggregation)2 DruidExpression (org.apache.druid.sql.calcite.expression.DruidExpression)2 QueryDataSource (org.apache.druid.query.QueryDataSource)1 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)1 DoubleSumAggregatorFactory (org.apache.druid.query.aggregation.DoubleSumAggregatorFactory)1 FilteredAggregatorFactory (org.apache.druid.query.aggregation.FilteredAggregatorFactory)1 IndexBuilder (org.apache.druid.segment.IndexBuilder)1 QueryableIndex (org.apache.druid.segment.QueryableIndex)1 ExpressionVirtualColumn (org.apache.druid.segment.virtual.ExpressionVirtualColumn)1 SpecificSegmentsQuerySegmentWalker (org.apache.druid.sql.calcite.util.SpecificSegmentsQuerySegmentWalker)1