use of org.apache.druid.query.groupby.orderby.DefaultLimitSpec in project druid by druid-io.
the class CalciteMultiValueStringQueryTest method testMultiValueStringOffsetOf.
@Test
public void testMultiValueStringOffsetOf() throws Exception {
// Cannot vectorize due to usage of expressions.
cannotVectorize();
testQuery("SELECT MV_OFFSET_OF(dim3, 'b'), SUM(cnt) FROM druid.numfoo GROUP BY 1 ORDER BY 2 DESC", ImmutableList.of(GroupByQuery.builder().setDataSource(CalciteTests.DATASOURCE3).setInterval(querySegmentSpec(Filtration.eternity())).setGranularity(Granularities.ALL).setVirtualColumns(expressionVirtualColumn("v0", "array_offset_of(\"dim3\",'b')", ColumnType.LONG)).setDimensions(dimensions(new DefaultDimensionSpec("v0", "_d0", ColumnType.LONG))).setAggregatorSpecs(aggregators(new LongSumAggregatorFactory("a0", "cnt"))).setLimitSpec(new DefaultLimitSpec(ImmutableList.of(new OrderByColumnSpec("a0", OrderByColumnSpec.Direction.DESCENDING, StringComparators.NUMERIC)), Integer.MAX_VALUE)).setContext(QUERY_CONTEXT_DEFAULT).build()), useDefault ? ImmutableList.of(new Object[] { 0, 4L }, new Object[] { -1, 1L }, new Object[] { 1, 1L }) : ImmutableList.of(new Object[] { null, 4L }, new Object[] { 0, 1L }, new Object[] { 1, 1L }));
}
use of org.apache.druid.query.groupby.orderby.DefaultLimitSpec in project druid by druid-io.
the class CalciteMultiValueStringQueryTest method testMultiValueStringPrependAppend.
@Test
public void testMultiValueStringPrependAppend() throws Exception {
// Cannot vectorize due to usage of expressions.
cannotVectorize();
ImmutableList<Object[]> results;
if (useDefault) {
results = ImmutableList.of(new Object[] { "", "", 3L }, new Object[] { "foo,a,b", "a,b,foo", 1L }, new Object[] { "foo,b,c", "b,c,foo", 1L }, new Object[] { "foo,d", "d,foo", 1L });
} else {
results = ImmutableList.of(new Object[] { null, null, 2L }, new Object[] { "foo,", ",foo", 1L }, new Object[] { "foo,a,b", "a,b,foo", 1L }, new Object[] { "foo,b,c", "b,c,foo", 1L }, new Object[] { "foo,d", "d,foo", 1L });
}
testQuery("SELECT MV_TO_STRING(MV_PREPEND('foo', dim3), ','), MV_TO_STRING(MV_APPEND(dim3, 'foo'), ','), SUM(cnt) FROM druid.numfoo GROUP BY 1,2 ORDER BY 3 DESC", ImmutableList.of(GroupByQuery.builder().setDataSource(CalciteTests.DATASOURCE3).setInterval(querySegmentSpec(Filtration.eternity())).setGranularity(Granularities.ALL).setVirtualColumns(expressionVirtualColumn("v0", "array_to_string(array_prepend('foo',\"dim3\"),',')", ColumnType.STRING), expressionVirtualColumn("v1", "array_to_string(array_append(\"dim3\",'foo'),',')", ColumnType.STRING)).setDimensions(dimensions(new DefaultDimensionSpec("v0", "_d0", ColumnType.STRING), new DefaultDimensionSpec("v1", "_d1", ColumnType.STRING))).setAggregatorSpecs(aggregators(new LongSumAggregatorFactory("a0", "cnt"))).setLimitSpec(new DefaultLimitSpec(ImmutableList.of(new OrderByColumnSpec("a0", OrderByColumnSpec.Direction.DESCENDING, StringComparators.NUMERIC)), Integer.MAX_VALUE)).setContext(QUERY_CONTEXT_DEFAULT).build()), results);
}
use of org.apache.druid.query.groupby.orderby.DefaultLimitSpec in project druid by druid-io.
the class CalciteMultiValueStringQueryTest method testMultiValueStringOrdinalOf.
@Test
public void testMultiValueStringOrdinalOf() throws Exception {
// Cannot vectorize due to usage of expressions.
cannotVectorize();
testQuery("SELECT MV_ORDINAL_OF(dim3, 'b'), SUM(cnt) FROM druid.numfoo GROUP BY 1 ORDER BY 2 DESC", ImmutableList.of(GroupByQuery.builder().setDataSource(CalciteTests.DATASOURCE3).setInterval(querySegmentSpec(Filtration.eternity())).setGranularity(Granularities.ALL).setVirtualColumns(expressionVirtualColumn("v0", "array_ordinal_of(\"dim3\",'b')", ColumnType.LONG)).setDimensions(dimensions(new DefaultDimensionSpec("v0", "_d0", ColumnType.LONG))).setAggregatorSpecs(aggregators(new LongSumAggregatorFactory("a0", "cnt"))).setLimitSpec(new DefaultLimitSpec(ImmutableList.of(new OrderByColumnSpec("a0", OrderByColumnSpec.Direction.DESCENDING, StringComparators.NUMERIC)), Integer.MAX_VALUE)).setContext(QUERY_CONTEXT_DEFAULT).build()), useDefault ? ImmutableList.of(new Object[] { 0, 3L }, new Object[] { -1, 1L }, new Object[] { 1, 1L }, new Object[] { 2, 1L }) : ImmutableList.of(new Object[] { null, 4L }, new Object[] { 1, 1L }, new Object[] { 2, 1L }));
}
use of org.apache.druid.query.groupby.orderby.DefaultLimitSpec in project druid by druid-io.
the class CalciteMultiValueStringQueryTest method testMultiValueListFilterComposedDeny.
@Test
public void testMultiValueListFilterComposedDeny() throws Exception {
// Cannot vectorize due to usage of expressions.
cannotVectorize();
testQuery("SELECT MV_LENGTH(MV_FILTER_NONE(dim3, ARRAY['b'])), SUM(cnt) FROM druid.numfoo GROUP BY 1 ORDER BY 2 DESC", ImmutableList.of(GroupByQuery.builder().setDataSource(CalciteTests.DATASOURCE3).setInterval(querySegmentSpec(Filtration.eternity())).setGranularity(Granularities.ALL).setVirtualColumns(expressionVirtualColumn("v0", "array_length(\"v1\")", ColumnType.LONG), new ListFilteredVirtualColumn("v1", DefaultDimensionSpec.of("dim3"), ImmutableSet.of("b"), false)).setDimensions(dimensions(new DefaultDimensionSpec("v0", "_d0", ColumnType.LONG))).setAggregatorSpecs(aggregators(new LongSumAggregatorFactory("a0", "cnt"))).setLimitSpec(new DefaultLimitSpec(ImmutableList.of(new OrderByColumnSpec("a0", OrderByColumnSpec.Direction.DESCENDING, StringComparators.NUMERIC)), Integer.MAX_VALUE)).setContext(QUERY_CONTEXT_DEFAULT).build()), useDefault ? ImmutableList.of(new Object[] { 0, 3L }, new Object[] { 1, 3L }) : ImmutableList.of(new Object[] { 1, 4L }, new Object[] { null, 2L }));
}
use of org.apache.druid.query.groupby.orderby.DefaultLimitSpec in project druid by druid-io.
the class CalciteMultiValueStringQueryTest method testMultiValueStringAppend.
@Test
public void testMultiValueStringAppend() throws Exception {
// Cannot vectorize due to usage of expressions.
cannotVectorize();
ImmutableList<Object[]> results;
if (useDefault) {
results = ImmutableList.of(new Object[] { "", 3L }, new Object[] { "foo", 3L }, new Object[] { "b", 2L }, new Object[] { "a", 1L }, new Object[] { "c", 1L }, new Object[] { "d", 1L });
} else {
results = ImmutableList.of(new Object[] { "foo", 4L }, new Object[] { null, 2L }, new Object[] { "b", 2L }, new Object[] { "", 1L }, new Object[] { "a", 1L }, new Object[] { "c", 1L }, new Object[] { "d", 1L });
}
testQuery("SELECT MV_APPEND(dim3, 'foo'), SUM(cnt) FROM druid.numfoo GROUP BY 1 ORDER BY 2 DESC", ImmutableList.of(GroupByQuery.builder().setDataSource(CalciteTests.DATASOURCE3).setInterval(querySegmentSpec(Filtration.eternity())).setGranularity(Granularities.ALL).setVirtualColumns(expressionVirtualColumn("v0", "array_append(\"dim3\",'foo')", ColumnType.STRING)).setDimensions(dimensions(new DefaultDimensionSpec("v0", "_d0", ColumnType.STRING))).setAggregatorSpecs(aggregators(new LongSumAggregatorFactory("a0", "cnt"))).setLimitSpec(new DefaultLimitSpec(ImmutableList.of(new OrderByColumnSpec("a0", OrderByColumnSpec.Direction.DESCENDING, StringComparators.NUMERIC)), Integer.MAX_VALUE)).setContext(QUERY_CONTEXT_DEFAULT).build()), results);
}
Aggregations