use of org.apache.druid.query.timeseries.TimeseriesQuery in project druid by druid-io.
the class LongLeastPostAggregatorTest method testResultArraySignature.
@Test
public void testResultArraySignature() {
final TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("dummy").intervals("2000/3000").granularity(Granularities.HOUR).aggregators(new CountAggregatorFactory("count")).postAggregators(new LongLeastPostAggregator("a", ImmutableList.of(new ConstantPostAggregator("_a", 3L), new ConstantPostAggregator("_b", 1.0f), new ConstantPostAggregator("_c", 5.0)))).build();
Assert.assertEquals(RowSignature.builder().addTimeColumn().add("count", ColumnType.LONG).add("a", ColumnType.LONG).build(), new TimeseriesQueryQueryToolChest().resultArraySignature(query));
}
use of org.apache.druid.query.timeseries.TimeseriesQuery in project druid by druid-io.
the class HyperUniqueFinalizingPostAggregatorTest method testResultArraySignature.
@Test
public void testResultArraySignature() {
final TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("dummy").intervals("2000/3000").granularity(Granularities.HOUR).aggregators(new CountAggregatorFactory("count"), new HyperUniquesAggregatorFactory("approxCount", "col"), new HyperUniquesAggregatorFactory("approxCountRound", "col", false, true)).postAggregators(new HyperUniqueFinalizingPostAggregator("a", "approxCount"), new HyperUniqueFinalizingPostAggregator("b", "approxCountRound")).build();
Assert.assertEquals(RowSignature.builder().addTimeColumn().add("count", ColumnType.LONG).add("approxCount", null).add("approxCountRound", null).add("a", ColumnType.DOUBLE).add("b", ColumnType.LONG).build(), new TimeseriesQueryQueryToolChest().resultArraySignature(query));
}
use of org.apache.druid.query.timeseries.TimeseriesQuery in project druid by druid-io.
the class ArithmeticPostAggregatorTest method testResultArraySignature.
@Test
public void testResultArraySignature() {
final TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("dummy").intervals("2000/3000").granularity(Granularities.HOUR).aggregators(new LongSumAggregatorFactory("sum", "col"), new CountAggregatorFactory("count")).postAggregators(new ArithmeticPostAggregator("avg", "/", ImmutableList.of(new FieldAccessPostAggregator("_count", "count"), new FieldAccessPostAggregator("_sum", "sum")))).build();
Assert.assertEquals(RowSignature.builder().addTimeColumn().add("sum", ColumnType.LONG).add("count", ColumnType.LONG).add("avg", ColumnType.DOUBLE).build(), new TimeseriesQueryQueryToolChest().resultArraySignature(query));
}
use of org.apache.druid.query.timeseries.TimeseriesQuery in project druid by druid-io.
the class DoubleGreatestPostAggregatorTest method testResultArraySignature.
@Test
public void testResultArraySignature() {
final TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("dummy").intervals("2000/3000").granularity(Granularities.HOUR).aggregators(new CountAggregatorFactory("count")).postAggregators(new DoubleGreatestPostAggregator("a", ImmutableList.of(new ConstantPostAggregator("_a", 3L), new ConstantPostAggregator("_b", 1.0f), new ConstantPostAggregator("_c", 5.0)))).build();
Assert.assertEquals(RowSignature.builder().addTimeColumn().add("count", ColumnType.LONG).add("a", ColumnType.DOUBLE).build(), new TimeseriesQueryQueryToolChest().resultArraySignature(query));
}
use of org.apache.druid.query.timeseries.TimeseriesQuery in project druid by druid-io.
the class ExpressionPostAggregatorTest method testResultArraySignature.
@Test
public void testResultArraySignature() {
final TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("dummy").intervals("2000/3000").granularity(Granularities.HOUR).aggregators(new CountAggregatorFactory("count"), new DoubleSumAggregatorFactory("double", "col1"), new FloatSumAggregatorFactory("float", "col2")).postAggregators(new ExpressionPostAggregator("a", "double + float", null, TestExprMacroTable.INSTANCE), new ExpressionPostAggregator("b", "count + count", null, TestExprMacroTable.INSTANCE), new ExpressionPostAggregator("c", "count + double", null, TestExprMacroTable.INSTANCE), new ExpressionPostAggregator("d", "float + float", null, TestExprMacroTable.INSTANCE)).build();
Assert.assertEquals(RowSignature.builder().addTimeColumn().add("count", ColumnType.LONG).add("double", ColumnType.DOUBLE).add("float", ColumnType.FLOAT).add("a", ColumnType.DOUBLE).add("b", ColumnType.LONG).add("c", ColumnType.DOUBLE).add("d", // floats don't exist in expressions
ColumnType.DOUBLE).build(), new TimeseriesQueryQueryToolChest().resultArraySignature(query));
}
Aggregations