Search in sources :

Example 1 with HumanReadableBytes

use of org.apache.druid.java.util.common.HumanReadableBytes in project druid by druid-io.

the class CalciteQueryTest method testStringAggMaxBytes.

@Test
public void testStringAggMaxBytes() throws Exception {
    cannotVectorize();
    testQuery("SELECT STRING_AGG(l1, ',', 128), STRING_AGG(DISTINCT l1, ',', 128) FROM numfoo", ImmutableList.of(Druids.newTimeseriesQueryBuilder().dataSource(CalciteTests.DATASOURCE3).intervals(querySegmentSpec(Filtration.eternity())).granularity(Granularities.ALL).aggregators(aggregators(new FilteredAggregatorFactory(new ExpressionLambdaAggregatorFactory("a0", ImmutableSet.of("l1"), "__acc", "[]", "[]", true, false, false, "array_append(\"__acc\", \"l1\")", "array_concat(\"__acc\", \"a0\")", null, "if(array_length(o) == 0, null, array_to_string(o, ','))", new HumanReadableBytes(128), TestExprMacroTable.INSTANCE), not(selector("l1", null, null))), new FilteredAggregatorFactory(new ExpressionLambdaAggregatorFactory("a1", ImmutableSet.of("l1"), "__acc", "[]", "[]", true, false, false, "array_set_add(\"__acc\", \"l1\")", "array_set_add_all(\"__acc\", \"a1\")", null, "if(array_length(o) == 0, null, array_to_string(o, ','))", new HumanReadableBytes(128), TestExprMacroTable.INSTANCE), not(selector("l1", null, null))))).context(QUERY_CONTEXT_DEFAULT).build()), ImmutableList.of(useDefault ? new Object[] { "7,325323,0,0,0,0", "0,325323,7" } : new Object[] { "7,325323,0", "0,325323,7" }));
}
Also used : FilteredAggregatorFactory(org.apache.druid.query.aggregation.FilteredAggregatorFactory) ExpressionLambdaAggregatorFactory(org.apache.druid.query.aggregation.ExpressionLambdaAggregatorFactory) HumanReadableBytes(org.apache.druid.java.util.common.HumanReadableBytes) Test(org.junit.Test)

Example 2 with HumanReadableBytes

use of org.apache.druid.java.util.common.HumanReadableBytes in project druid by druid-io.

the class CalciteArraysQueryTest method testArrayAggMaxBytes.

@Test
public void testArrayAggMaxBytes() throws Exception {
    cannotVectorize();
    testQuery("SELECT ARRAY_AGG(l1, 128), ARRAY_AGG(DISTINCT l1, 128) FROM numfoo", ImmutableList.of(Druids.newTimeseriesQueryBuilder().dataSource(CalciteTests.DATASOURCE3).intervals(querySegmentSpec(Filtration.eternity())).granularity(Granularities.ALL).aggregators(aggregators(new ExpressionLambdaAggregatorFactory("a0", ImmutableSet.of("l1"), "__acc", "ARRAY<LONG>[]", "ARRAY<LONG>[]", true, true, false, "array_append(\"__acc\", \"l1\")", "array_concat(\"__acc\", \"a0\")", null, null, new HumanReadableBytes(128), TestExprMacroTable.INSTANCE), new ExpressionLambdaAggregatorFactory("a1", ImmutableSet.of("l1"), "__acc", "ARRAY<LONG>[]", "ARRAY<LONG>[]", true, true, false, "array_set_add(\"__acc\", \"l1\")", "array_set_add_all(\"__acc\", \"a1\")", null, null, new HumanReadableBytes(128), TestExprMacroTable.INSTANCE))).context(QUERY_CONTEXT_DEFAULT).build()), ImmutableList.of(useDefault ? new Object[] { "[7,325323,0,0,0,0]", "[0,7,325323]" } : new Object[] { "[7,325323,0,null,null,null]", "[null,0,7,325323]" }));
}
Also used : ExpressionLambdaAggregatorFactory(org.apache.druid.query.aggregation.ExpressionLambdaAggregatorFactory) HumanReadableBytes(org.apache.druid.java.util.common.HumanReadableBytes) Test(org.junit.Test)

Example 3 with HumanReadableBytes

use of org.apache.druid.java.util.common.HumanReadableBytes in project druid by druid-io.

the class ExpressionLambdaAggregatorFactoryTest method testLongArrayType.

@Test
public void testLongArrayType() {
    ExpressionLambdaAggregatorFactory agg = new ExpressionLambdaAggregatorFactory("expr_agg_name", ImmutableSet.of("some_column", "some_other_column"), null, "0", "ARRAY<LONG>[]", null, false, false, "__acc + some_column + some_other_column", "array_set_add(__acc, expr_agg_name)", null, null, new HumanReadableBytes(2048), TestExprMacroTable.INSTANCE);
    Assert.assertEquals(ColumnType.LONG, agg.getIntermediateType());
    Assert.assertEquals(ColumnType.LONG_ARRAY, agg.getCombiningFactory().getIntermediateType());
    Assert.assertEquals(ColumnType.LONG_ARRAY, agg.getResultType());
}
Also used : HumanReadableBytes(org.apache.druid.java.util.common.HumanReadableBytes) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 4 with HumanReadableBytes

use of org.apache.druid.java.util.common.HumanReadableBytes in project druid by druid-io.

the class ExpressionLambdaAggregatorFactoryTest method testComplexType.

@Test
public void testComplexType() {
    ExpressionLambdaAggregatorFactory agg = new ExpressionLambdaAggregatorFactory("expr_agg_name", ImmutableSet.of("some_column"), null, "hyper_unique()", null, null, false, false, "hyper_unique_add(some_column, __acc)", "hyper_unique_add(__acc, expr_agg_name)", null, null, new HumanReadableBytes(2048), TestExprMacroTable.INSTANCE);
    Assert.assertEquals(HyperUniquesAggregatorFactory.TYPE, agg.getIntermediateType());
    Assert.assertEquals(HyperUniquesAggregatorFactory.TYPE, agg.getCombiningFactory().getIntermediateType());
    Assert.assertEquals(HyperUniquesAggregatorFactory.TYPE, agg.getResultType());
}
Also used : HumanReadableBytes(org.apache.druid.java.util.common.HumanReadableBytes) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 5 with HumanReadableBytes

use of org.apache.druid.java.util.common.HumanReadableBytes in project druid by druid-io.

the class ExpressionLambdaAggregatorFactoryTest method testDoubleArrayType.

@Test
public void testDoubleArrayType() {
    ExpressionLambdaAggregatorFactory agg = new ExpressionLambdaAggregatorFactory("expr_agg_name", ImmutableSet.of("some_column", "some_other_column"), null, "0.0", "ARRAY<DOUBLE>[]", null, false, false, "__acc + some_column + some_other_column", "array_set_add(__acc, expr_agg_name)", null, null, new HumanReadableBytes(2048), TestExprMacroTable.INSTANCE);
    Assert.assertEquals(ColumnType.DOUBLE, agg.getIntermediateType());
    Assert.assertEquals(ColumnType.DOUBLE_ARRAY, agg.getCombiningFactory().getIntermediateType());
    Assert.assertEquals(ColumnType.DOUBLE_ARRAY, agg.getResultType());
}
Also used : HumanReadableBytes(org.apache.druid.java.util.common.HumanReadableBytes) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Aggregations

HumanReadableBytes (org.apache.druid.java.util.common.HumanReadableBytes)39 Test (org.junit.Test)35 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)19 List (java.util.List)7 MaxSizeSplitHintSpec (org.apache.druid.data.input.MaxSizeSplitHintSpec)6 ExpressionLambdaAggregatorFactory (org.apache.druid.query.aggregation.ExpressionLambdaAggregatorFactory)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 InputSplit (org.apache.druid.data.input.InputSplit)4 SegmentsSplitHintSpec (org.apache.druid.data.input.SegmentsSplitHintSpec)4 DynamicPartitionsSpec (org.apache.druid.indexer.partitions.DynamicPartitionsSpec)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 File (java.io.File)3 Collectors (java.util.stream.Collectors)3 Nullable (javax.annotation.Nullable)3 AggregateCall (org.apache.calcite.rel.core.AggregateCall)3 Project (org.apache.calcite.rel.core.Project)3 RexBuilder (org.apache.calcite.rex.RexBuilder)3 RexLiteral (org.apache.calcite.rex.RexLiteral)3 RexNode (org.apache.calcite.rex.RexNode)3 SqlAggFunction (org.apache.calcite.sql.SqlAggFunction)3