This is an automated email from the ASF dual-hosted git repository.
vogievetsky pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new e7c8f2e2083 lift restriction of array_to_mv to only support direct
column access (#15528)
e7c8f2e2083 is described below
commit e7c8f2e20832d26d19748674b5ceb77fbcc63274
Author: Clint Wylie <[email protected]>
AuthorDate: Fri Dec 8 16:27:17 2023 -0800
lift restriction of array_to_mv to only support direct column access
(#15528)
---
.../java/org/apache/druid/math/expr/Function.java | 8 ----
.../org/apache/druid/math/expr/FunctionTest.java | 7 +++
.../ArrayToMultiValueStringOperatorConversion.java | 2 -
.../sql/calcite/CalciteNestedDataQueryTest.java | 52 ++++++++++++++++++++++
4 files changed, 59 insertions(+), 10 deletions(-)
diff --git a/processing/src/main/java/org/apache/druid/math/expr/Function.java
b/processing/src/main/java/org/apache/druid/math/expr/Function.java
index 61bce0b2b20..3f90f7c3999 100644
--- a/processing/src/main/java/org/apache/druid/math/expr/Function.java
+++ b/processing/src/main/java/org/apache/druid/math/expr/Function.java
@@ -3231,14 +3231,6 @@ public interface Function extends NamedFunction
public void validateArguments(List<Expr> args)
{
validationHelperCheckArgumentCount(args, 1);
- IdentifierExpr expr = args.get(0).getIdentifierExprIfIdentifierExpr();
-
- if (expr == null) {
- throw validationFailed(
- "argument %s should be an identifier expression. Use array()
instead",
- args.get(0).toString()
- );
- }
}
@Nullable
diff --git
a/processing/src/test/java/org/apache/druid/math/expr/FunctionTest.java
b/processing/src/test/java/org/apache/druid/math/expr/FunctionTest.java
index b359ec27c27..e38b2ea5145 100644
--- a/processing/src/test/java/org/apache/druid/math/expr/FunctionTest.java
+++ b/processing/src/test/java/org/apache/druid/math/expr/FunctionTest.java
@@ -1163,6 +1163,13 @@ public class FunctionTest extends
InitializedNullHandlingTest
assertArrayExpr("array_to_mv(a)", new String[]{"foo", "bar", "baz",
"foobar"});
assertArrayExpr("array_to_mv(b)", new String[]{"1", "2", "3", "4", "5"});
assertArrayExpr("array_to_mv(c)", new String[]{"3.1", "4.2", "5.3"});
+ assertArrayExpr("array_to_mv(array(y,z))", new String[]{"2", "3"});
+ // array type is determined by the first array type
+ assertArrayExpr("array_to_mv(array_concat(b,c))", new String[]{"1", "2",
"3", "4", "5", "3", "4", "5"});
+ assertArrayExpr(
+ "array_to_mv(array_concat(c,b))",
+ new String[]{"3.1", "4.2", "5.3", "1.0", "2.0", "3.0", "4.0", "5.0"}
+ );
}
@Test
diff --git
a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/ArrayToMultiValueStringOperatorConversion.java
b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/ArrayToMultiValueStringOperatorConversion.java
index 551df41b97a..eb1ea63541c 100644
---
a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/ArrayToMultiValueStringOperatorConversion.java
+++
b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/ArrayToMultiValueStringOperatorConversion.java
@@ -45,6 +45,4 @@ public class ArrayToMultiValueStringOperatorConversion
extends DirectOperatorCon
{
super(SQL_FUNCTION, "array_to_mv");
}
-
-
}
diff --git
a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteNestedDataQueryTest.java
b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteNestedDataQueryTest.java
index 8261694df5b..90b3932d1e6 100644
---
a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteNestedDataQueryTest.java
+++
b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteNestedDataQueryTest.java
@@ -5344,6 +5344,58 @@ public class CalciteNestedDataQueryTest extends
BaseCalciteQueryTest
.run();
}
+ @Test
+ public void testGroupByRootSingleTypeArrayLongNullsAsMvdWithExpression()
+ {
+ cannotVectorize();
+ testBuilder()
+ .sql(
+ "SELECT "
+ + "ARRAY_TO_MV(ARRAY_CONCAT(arrayLongNulls, arrayLong)), "
+ + "SUM(cnt) "
+ + "FROM druid.arrays GROUP BY 1"
+ )
+ .queryContext(QUERY_CONTEXT_NO_STRINGIFY_ARRAY)
+ .expectedQueries(
+ ImmutableList.of(
+ GroupByQuery.builder()
+
.setDataSource(TableDataSource.create(DATA_SOURCE_ARRAYS))
+
.setInterval(querySegmentSpec(Filtration.eternity()))
+ .setGranularity(Granularities.ALL)
+ .setDimensions(
+ dimensions(
+ new DefaultDimensionSpec("v0", "d0",
ColumnType.STRING)
+ )
+ )
+ .setVirtualColumns(expressionVirtualColumn(
+ "v0",
+
"array_to_mv(array_concat(\"arrayLongNulls\",\"arrayLong\"))",
+ ColumnType.STRING
+ ))
+ .setAggregatorSpecs(aggregators(new
LongSumAggregatorFactory("a0", "cnt")))
+ .setContext(QUERY_CONTEXT_NO_STRINGIFY_ARRAY)
+ .build()
+ )
+ )
+ .expectedResults(
+ // 9 isn't present in result because arrayLong rows are null in
rows of arrayLongNulls that have value 9
+ ImmutableList.of(
+ new Object[]{NullHandling.defaultStringValue(), 10L},
+ new Object[]{"1", 12L},
+ new Object[]{"2", 7L},
+ new Object[]{"3", 9L},
+ new Object[]{"4", 4L}
+ )
+ )
+ .expectedSignature(
+ RowSignature.builder()
+ .add("EXPR$0", ColumnType.STRING)
+ .add("EXPR$1", ColumnType.LONG)
+ .build()
+ )
+ .run();
+ }
+
/**
* MVD version of {@link #testGroupByRootSingleTypeArrayLongNullsFiltered()}
* - implicit unnest since it is an mvd instead of array grouping
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]