diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java index 0884e3d414..e531c34994 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java @@ -1082,6 +1082,11 @@ public class FunctionCallExpr extends Expr { throw new AnalysisException(getFunctionNotFoundError(collectChildReturnTypes())); } + if (fnName.getFunction().equalsIgnoreCase("collect_list") + || fnName.getFunction().equalsIgnoreCase("collect_set")) { + fn.setReturnType(new ArrayType(getChild(0).type)); + } + applyAutoTypeConversionForDatetimeV2(); if (fnName.getFunction().equalsIgnoreCase("from_unixtime") diff --git a/regression-test/data/query_p0/sql_functions/aggregate_functions/test_aggregate_collect.out b/regression-test/data/query_p0/sql_functions/aggregate_functions/test_aggregate_collect.out index b18f47128c..d501683f7f 100644 --- a/regression-test/data/query_p0/sql_functions/aggregate_functions/test_aggregate_collect.out +++ b/regression-test/data/query_p0/sql_functions/aggregate_functions/test_aggregate_collect.out @@ -13,3 +13,6 @@ -- !select -- ['hello'] ['hello'] +-- !select -- +1 [1, 2, 1, 2] ['hello'] [2022-07-04, 2022-07-04] [1.23] ['hello', 'hello', 'hello', 'hello'] + diff --git a/regression-test/suites/query_p0/sql_functions/aggregate_functions/test_aggregate_collect.groovy b/regression-test/suites/query_p0/sql_functions/aggregate_functions/test_aggregate_collect.groovy index 3d3b8a00d4..cd7e61d408 100644 --- a/regression-test/suites/query_p0/sql_functions/aggregate_functions/test_aggregate_collect.groovy +++ b/regression-test/suites/query_p0/sql_functions/aggregate_functions/test_aggregate_collect.groovy @@ -19,7 +19,9 @@ suite("test_aggregate_collect") { sql "set enable_vectorized_engine = true" def tableName = "collect_test" + def tableCTAS = "collect_test_ctas" sql "DROP TABLE IF EXISTS ${tableName}" + sql "DROP TABLE IF EXISTS ${tableCTAS}" sql """ CREATE TABLE IF NOT EXISTS ${tableName} ( c_int INT, @@ -42,4 +44,7 @@ suite("test_aggregate_collect") { // test without GROUP BY qt_select "select collect_list(c_string),collect_list(c_string_not_null) from ${tableName}" qt_select "select collect_set(c_string),collect_set(c_string_not_null) from ${tableName}" + + sql """ CREATE TABLE ${tableCTAS} PROPERTIES("replication_num" = "1") AS SELECT 1,collect_list(c_int),collect_set(c_string),collect_list(c_date),collect_set(c_decimal),collect_list(c_string_not_null) FROM ${tableName} """ + qt_select "SELECT * from ${tableCTAS}" }