use of org.apache.druid.query.groupby.orderby.OrderByColumnSpec in project druid by druid-io.
the class CalciteMultiValueStringQueryTest method testMultiValueListFilterDeny.
@Test
public void testMultiValueListFilterDeny() throws Exception {
// Cannot vectorize due to usage of expressions.
cannotVectorize();
testQuery("SELECT 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(new ListFilteredVirtualColumn("v0", DefaultDimensionSpec.of("dim3"), ImmutableSet.of("b"), false)).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()), useDefault ? ImmutableList.of(new Object[] { NullHandling.defaultStringValue(), 3L }, new Object[] { "a", 1L }, new Object[] { "c", 1L }, new Object[] { "d", 1L }) : ImmutableList.of(new Object[] { NullHandling.defaultStringValue(), 2L }, new Object[] { "", 1L }, new Object[] { "a", 1L }, new Object[] { "c", 1L }, new Object[] { "d", 1L }));
}
use of org.apache.druid.query.groupby.orderby.OrderByColumnSpec in project druid by druid-io.
the class CalciteQueryTest method testGroupByFormatYearAndMonth.
@Test
public void testGroupByFormatYearAndMonth() throws Exception {
// Cannot vectorize due to virtual columns.
cannotVectorize();
testQuery("SELECT\n" + " TIME_FORMAt(__time, 'yyyy MM') AS \"year\",\n" + " SUM(cnt)\n" + "FROM druid.foo\n" + "GROUP BY TIME_FORMAt(__time, 'yyyy MM')\n" + "ORDER BY 1", ImmutableList.of(GroupByQuery.builder().setDataSource(CalciteTests.DATASOURCE1).setInterval(querySegmentSpec(Filtration.eternity())).setGranularity(Granularities.ALL).setVirtualColumns(expressionVirtualColumn("v0", "timestamp_format(\"__time\",'yyyy MM','UTC')", ColumnType.STRING)).setDimensions(dimensions(new DefaultDimensionSpec("v0", "d0", ColumnType.STRING))).setAggregatorSpecs(aggregators(new LongSumAggregatorFactory("a0", "cnt"))).setLimitSpec(new DefaultLimitSpec(ImmutableList.of(new OrderByColumnSpec("d0", OrderByColumnSpec.Direction.ASCENDING, StringComparators.LEXICOGRAPHIC)), Integer.MAX_VALUE)).setContext(QUERY_CONTEXT_DEFAULT).build()), ImmutableList.of(new Object[] { "2000 01", 3L }, new Object[] { "2001 01", 3L }));
}
use of org.apache.druid.query.groupby.orderby.OrderByColumnSpec in project druid by druid-io.
the class CalciteQueryTest method testBitwiseAggregatorsGroupBy.
@Test
public void testBitwiseAggregatorsGroupBy() throws Exception {
cannotVectorize();
testQuery("SELECT\n" + " dim2,\n" + " BIT_AND(l1),\n" + " BIT_OR(l1),\n" + " BIT_XOR(l1)\n" + "FROM druid.numfoo GROUP BY 1 ORDER BY 4", ImmutableList.of(GroupByQuery.builder().setDataSource(CalciteTests.DATASOURCE3).setInterval(querySegmentSpec(Filtration.eternity())).setGranularity(Granularities.ALL).setDimensions(new DefaultDimensionSpec("dim2", "_d0", ColumnType.STRING)).setAggregatorSpecs(aggregators(new FilteredAggregatorFactory(new ExpressionLambdaAggregatorFactory("a0", ImmutableSet.of("l1"), "__acc", "0", "0", NullHandling.sqlCompatible(), false, false, "bitwiseAnd(\"__acc\", \"l1\")", "bitwiseAnd(\"__acc\", \"a0\")", null, null, ExpressionLambdaAggregatorFactory.DEFAULT_MAX_SIZE_BYTES, TestExprMacroTable.INSTANCE), not(selector("l1", null, null))), new FilteredAggregatorFactory(new ExpressionLambdaAggregatorFactory("a1", ImmutableSet.of("l1"), "__acc", "0", "0", NullHandling.sqlCompatible(), false, false, "bitwiseOr(\"__acc\", \"l1\")", "bitwiseOr(\"__acc\", \"a1\")", null, null, ExpressionLambdaAggregatorFactory.DEFAULT_MAX_SIZE_BYTES, TestExprMacroTable.INSTANCE), not(selector("l1", null, null))), new FilteredAggregatorFactory(new ExpressionLambdaAggregatorFactory("a2", ImmutableSet.of("l1"), "__acc", "0", "0", NullHandling.sqlCompatible(), false, false, "bitwiseXor(\"__acc\", \"l1\")", "bitwiseXor(\"__acc\", \"a2\")", null, null, ExpressionLambdaAggregatorFactory.DEFAULT_MAX_SIZE_BYTES, TestExprMacroTable.INSTANCE), not(selector("l1", null, null))))).setLimitSpec(DefaultLimitSpec.builder().orderBy(new OrderByColumnSpec("a2", Direction.ASCENDING, StringComparators.NUMERIC)).build()).setContext(QUERY_CONTEXT_DEFAULT).build()), useDefault ? ImmutableList.of(new Object[] { "abc", 0L, 0L, 0L }, new Object[] { "a", 0L, 7L, 7L }, new Object[] { "", 0L, 325323L, 325323L }) : ImmutableList.of(new Object[] { "abc", null, null, null }, new Object[] { "", 0L, 0L, 0L }, new Object[] { "a", 0L, 7L, 7L }, new Object[] { null, 0L, 325323L, 325323L }));
}
use of org.apache.druid.query.groupby.orderby.OrderByColumnSpec in project druid by druid-io.
the class CalciteArraysQueryTest method testArrayGroupAsFloatArray.
@Test
public void testArrayGroupAsFloatArray() throws Exception {
// Cannot vectorize as we donot have support in native query subsytem for grouping on arrays as keys
cannotVectorize();
testQuery("SELECT ARRAY[f1], SUM(cnt) FROM druid.numfoo GROUP BY 1 ORDER BY 2 DESC", QUERY_CONTEXT_NO_STRINGIFY_ARRAY, ImmutableList.of(GroupByQuery.builder().setDataSource(CalciteTests.DATASOURCE3).setInterval(querySegmentSpec(Filtration.eternity())).setGranularity(Granularities.ALL).setVirtualColumns(expressionVirtualColumn("v0", "array(\"f1\")", ColumnType.ofArray(ColumnType.FLOAT))).setDimensions(dimensions(new DefaultDimensionSpec("v0", "_d0", ColumnType.ofArray(ColumnType.FLOAT)))).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_NO_STRINGIFY_ARRAY).build()), useDefault ? ImmutableList.of(new Object[] { ImmutableList.of(0.0), 4L }, new Object[] { ImmutableList.of(0.10000000149011612), 1L }, new Object[] { ImmutableList.of(1.0), 1L }) : ImmutableList.of(new Object[] { Collections.singletonList(null), 3L }, new Object[] { ImmutableList.of(0.0), 1L }, new Object[] { ImmutableList.of(0.10000000149011612), 1L }, new Object[] { ImmutableList.of(1.0), 1L }));
}
use of org.apache.druid.query.groupby.orderby.OrderByColumnSpec in project druid by druid-io.
the class CalciteArraysQueryTest method testArrayOffset.
@Test
public void testArrayOffset() throws Exception {
// Cannot vectorize due to usage of expressions.
cannotVectorize();
testQuery("SELECT ARRAY_OFFSET(dim3, 1), 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(\"dim3\",1)", 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()), ImmutableList.of(new Object[] { NullHandling.defaultStringValue(), 4L }, new Object[] { "b", 1L }, new Object[] { "c", 1L }));
}
Aggregations