use of org.apache.druid.query.topn.NumericTopNMetricSpec in project druid by druid-io.
the class CalciteQueryTest method testOrderByEarliestDouble.
@Test
public void testOrderByEarliestDouble() throws Exception {
// Cannot vectorize EARLIEST aggregator.
skipVectorize();
List<Object[]> expected;
if (NullHandling.replaceWithDefault()) {
expected = ImmutableList.of(new Object[] { "1", 0.0 }, new Object[] { "2", 0.0 }, new Object[] { "abc", 0.0 }, new Object[] { "def", 0.0 }, new Object[] { "", 1.0 }, new Object[] { "10.1", 1.7 });
} else {
expected = ImmutableList.of(new Object[] { "1", null }, new Object[] { "abc", null }, new Object[] { "def", null }, new Object[] { "2", 0.0 }, new Object[] { "", 1.0 }, new Object[] { "10.1", 1.7 });
}
testQuery("SELECT dim1, EARLIEST(d1) FROM druid.numfoo GROUP BY 1 ORDER BY 2 LIMIT 10", ImmutableList.of(new TopNQueryBuilder().dataSource(CalciteTests.DATASOURCE3).intervals(querySegmentSpec(Filtration.eternity())).granularity(Granularities.ALL).dimension(new DefaultDimensionSpec("dim1", "_d0")).aggregators(aggregators(new DoubleFirstAggregatorFactory("a0", "d1", null))).metric(new InvertedTopNMetricSpec(new NumericTopNMetricSpec("a0"))).threshold(10).context(QUERY_CONTEXT_DEFAULT).build()), expected);
}
use of org.apache.druid.query.topn.NumericTopNMetricSpec in project druid by druid-io.
the class CalciteQueryTest method testOrderByAnyLong.
@Test
public void testOrderByAnyLong() throws Exception {
List<Object[]> expected;
if (NullHandling.replaceWithDefault()) {
expected = ImmutableList.of(new Object[] { "1", 0L }, new Object[] { "2", 0L }, new Object[] { "abc", 0L }, new Object[] { "def", 0L }, new Object[] { "", 7L }, new Object[] { "10.1", 325323L });
} else {
expected = ImmutableList.of(new Object[] { "2", 0L }, new Object[] { "", 7L }, new Object[] { "10.1", 325323L }, // reversed by TopNNumericResultBuilder.build()
new Object[] { "1", null }, new Object[] { "abc", null }, new Object[] { "def", null });
}
testQuery("SELECT dim1, ANY_VALUE(l1) FROM druid.numfoo GROUP BY 1 ORDER BY 2 LIMIT 10", ImmutableList.of(new TopNQueryBuilder().dataSource(CalciteTests.DATASOURCE3).intervals(querySegmentSpec(Filtration.eternity())).granularity(Granularities.ALL).dimension(new DefaultDimensionSpec("dim1", "_d0")).aggregators(aggregators(new LongAnyAggregatorFactory("a0", "l1"))).metric(new InvertedTopNMetricSpec(new NumericTopNMetricSpec("a0"))).threshold(10).context(QUERY_CONTEXT_DEFAULT).build()), expected);
}
Aggregations