use of org.apache.druid.query.aggregation.post.FieldAccessPostAggregator in project druid by druid-io.
the class DoublesSketchToQuantilesPostAggregatorTest method testComparator.
@Test
public void testComparator() {
expectedException.expect(IAE.class);
expectedException.expectMessage("Comparing arrays of quantiles is not supported");
final PostAggregator postAgg = new DoublesSketchToQuantilesPostAggregator("post", new FieldAccessPostAggregator("field1", "sketch"), new double[] { 0, 0.5, 1 });
postAgg.getComparator();
}
use of org.apache.druid.query.aggregation.post.FieldAccessPostAggregator in project druid by druid-io.
the class DoublesSketchToQuantilesPostAggregatorTest method testResultArraySignature.
@Test
public void testResultArraySignature() {
final TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("dummy").intervals("2000/3000").granularity(Granularities.HOUR).aggregators(new DoublesSketchAggregatorFactory("sketch", "col", 8)).postAggregators(new DoublesSketchToQuantilesPostAggregator("a", new FieldAccessPostAggregator("field", "sketch"), new double[] { 0, 0.5, 1 })).build();
Assert.assertEquals(RowSignature.builder().addTimeColumn().add("sketch", null).add("a", ColumnType.DOUBLE_ARRAY).build(), new TimeseriesQueryQueryToolChest().resultArraySignature(query));
}
use of org.apache.druid.query.aggregation.post.FieldAccessPostAggregator in project druid by druid-io.
the class DoublesSketchToQuantilesPostAggregatorTest method emptySketch.
@Test
public void emptySketch() {
final TestDoubleColumnSelectorImpl selector = new TestDoubleColumnSelectorImpl(null);
final Aggregator agg = new DoublesSketchBuildAggregator(selector, 8);
final Map<String, Object> fields = new HashMap<>();
fields.put("sketch", agg.get());
final PostAggregator postAgg = new DoublesSketchToQuantilesPostAggregator("quantiles", new FieldAccessPostAggregator("field", "sketch"), new double[] { 0, 0.5, 1 });
final double[] quantiles = (double[]) postAgg.compute(fields);
Assert.assertNotNull(quantiles);
Assert.assertEquals(3, quantiles.length);
Assert.assertTrue(Double.isNaN(quantiles[0]));
Assert.assertTrue(Double.isNaN(quantiles[1]));
Assert.assertTrue(Double.isNaN(quantiles[2]));
}
use of org.apache.druid.query.aggregation.post.FieldAccessPostAggregator in project druid by druid-io.
the class DoublesSketchToQuantilesPostAggregatorTest method testSerde.
@Test
public void testSerde() throws JsonProcessingException {
final PostAggregator there = new DoublesSketchToQuantilesPostAggregator("post", new FieldAccessPostAggregator("field1", "sketch"), new double[] { 0, 0.5, 1 });
DefaultObjectMapper mapper = new DefaultObjectMapper();
DoublesSketchToQuantilesPostAggregator andBackAgain = mapper.readValue(mapper.writeValueAsString(there), DoublesSketchToQuantilesPostAggregator.class);
Assert.assertEquals(there, andBackAgain);
Assert.assertArrayEquals(there.getCacheKey(), andBackAgain.getCacheKey());
}
use of org.apache.druid.query.aggregation.post.FieldAccessPostAggregator in project druid by druid-io.
the class DoublesSketchToStringPostAggregatorTest method testToString.
@Test
public void testToString() {
final PostAggregator postAgg = new DoublesSketchToStringPostAggregator("post", new FieldAccessPostAggregator("field1", "sketch"));
Assert.assertEquals("DoublesSketchToStringPostAggregator{name='post', field=FieldAccessPostAggregator{name='field1', fieldName='sketch'}}", postAgg.toString());
}
Aggregations