use of org.apache.druid.query.aggregation.histogram.FixedBucketsHistogramAggregatorFactory in project druid by druid-io.
the class FixedBucketsHistogramQuantileSqlAggregatorTest method createQuerySegmentWalker.
@Override
public SpecificSegmentsQuerySegmentWalker createQuerySegmentWalker() throws IOException {
ApproximateHistogramDruidModule.registerSerde();
final QueryableIndex index = IndexBuilder.create(CalciteTests.getJsonMapper()).tmpDir(temporaryFolder.newFolder()).segmentWriteOutMediumFactory(OffHeapMemorySegmentWriteOutMediumFactory.instance()).schema(new IncrementalIndexSchema.Builder().withMetrics(new CountAggregatorFactory("cnt"), new DoubleSumAggregatorFactory("m1", "m1"), new FixedBucketsHistogramAggregatorFactory("fbhist_m1", "m1", 20, 0, 10, FixedBucketsHistogram.OutlierHandlingMode.IGNORE, false)).withRollup(false).build()).rows(CalciteTests.ROWS1).buildMMappedIndex();
return new SpecificSegmentsQuerySegmentWalker(conglomerate).add(DataSegment.builder().dataSource(CalciteTests.DATASOURCE1).interval(index.getDataInterval()).version("1").shardSpec(new LinearShardSpec(0)).size(0).build(), index);
}
use of org.apache.druid.query.aggregation.histogram.FixedBucketsHistogramAggregatorFactory in project druid by druid-io.
the class FixedBucketsHistogramQuantileSqlAggregatorTest method testGroupByAggregatorDefaultValues.
@Test
public void testGroupByAggregatorDefaultValues() throws Exception {
cannotVectorize();
testQuery("SELECT\n" + "dim2,\n" + "APPROX_QUANTILE_FIXED_BUCKETS(fbhist_m1, 0.01, 20, 0.0, 10.0) FILTER(WHERE dim1 = 'nonexistent'),\n" + "APPROX_QUANTILE_FIXED_BUCKETS(m1, 0.01, 20, 0.0, 10.0) FILTER(WHERE dim1 = 'nonexistent')\n" + "FROM foo WHERE dim2 = 'a' GROUP BY dim2", ImmutableList.of(GroupByQuery.builder().setDataSource(CalciteTests.DATASOURCE1).setInterval(querySegmentSpec(Filtration.eternity())).setDimFilter(selector("dim2", "a", null)).setGranularity(Granularities.ALL).setVirtualColumns(expressionVirtualColumn("v0", "'a'", ColumnType.STRING)).setDimensions(new DefaultDimensionSpec("v0", "d0", ColumnType.STRING)).setAggregatorSpecs(aggregators(new FilteredAggregatorFactory(new FixedBucketsHistogramAggregatorFactory("a0:agg", "fbhist_m1", 20, 0.0, 10.0, FixedBucketsHistogram.OutlierHandlingMode.IGNORE, false), selector("dim1", "nonexistent", null)), new FilteredAggregatorFactory(new FixedBucketsHistogramAggregatorFactory("a1:agg", "m1", 20, 0.0, 10.0, FixedBucketsHistogram.OutlierHandlingMode.IGNORE, false), selector("dim1", "nonexistent", null)))).setPostAggregatorSpecs(ImmutableList.of(new QuantilePostAggregator("a0", "a0:agg", 0.01f), new QuantilePostAggregator("a1", "a1:agg", 0.01f))).setContext(QUERY_CONTEXT_DEFAULT).build()), ImmutableList.of(new Object[] { "a", 0.0, 0.0 }));
}
Aggregations