This is an automated email from the ASF dual-hosted git repository. xuyang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 49b060418a [optimization](array-type) array_min/array_max function support the date/datetime type (#13407) 49b060418a is described below commit 49b060418ad6a6a0d182f483d5ab0eacc414a563 Author: carlvinhust2012 <huchengha...@126.com> AuthorDate: Mon Oct 17 23:38:20 2022 +0800 [optimization](array-type) array_min/array_max function support the date/datetime type (#13407) This pr is used to expand the supported data type for array_min/array_max function. Before the change , the array_min/array_max function can't support the date/datetime type. After the change, array_min/array_max function can support the date/datetime type. Co-authored-by: hucheng01 <huchen...@baidu.com> --- .../functions/array/function_array_aggregation.cpp | 6 ++++- gensrc/script/doris_builtins_functions.py | 8 ++++++ .../test_array_aggregation_functions.out | 31 +++++++++++----------- .../test_array_aggregation_functions.groovy | 6 ++--- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/be/src/vec/functions/array/function_array_aggregation.cpp b/be/src/vec/functions/array/function_array_aggregation.cpp index f09a0a72fa..aed53bc25b 100644 --- a/be/src/vec/functions/array/function_array_aggregation.cpp +++ b/be/src/vec/functions/array/function_array_aggregation.cpp @@ -166,7 +166,11 @@ struct ArrayAggregateImpl { execute_type<Int128>(res, type, data, offsets) || execute_type<Float32>(res, type, data, offsets) || execute_type<Float64>(res, type, data, offsets) || - execute_type<Decimal128>(res, type, data, offsets)) { + execute_type<Decimal128>(res, type, data, offsets) || + execute_type<Date>(res, type, data, offsets) || + execute_type<DateTime>(res, type, data, offsets) || + execute_type<DateV2>(res, type, data, offsets) || + execute_type<DateTimeV2>(res, type, data, offsets)) { block.replace_by_position(result, std::move(res)); return Status::OK(); } else { diff --git a/gensrc/script/doris_builtins_functions.py b/gensrc/script/doris_builtins_functions.py index c27212fc8d..01fbda64d0 100755 --- a/gensrc/script/doris_builtins_functions.py +++ b/gensrc/script/doris_builtins_functions.py @@ -272,6 +272,10 @@ visible_functions = [ [['array_min'], 'FLOAT', ['ARRAY_FLOAT'], '', '', '', 'vec', 'ALWAYS_NULLABLE'], [['array_min'], 'DOUBLE', ['ARRAY_DOUBLE'], '', '', '', 'vec', 'ALWAYS_NULLABLE'], [['array_min'], 'DECIMALV2',['ARRAY_DECIMALV2'],'', '', '', 'vec', 'ALWAYS_NULLABLE'], + [['array_min'], 'DATE', ['ARRAY_DATE'], '', '', '', 'vec', 'ALWAYS_NULLABLE'], + [['array_min'], 'DATETIME', ['ARRAY_DATETIME'], '', '', '', 'vec', 'ALWAYS_NULLABLE'], + [['array_min'], 'DATEV2', ['ARRAY_DATEV2'], '', '', '', 'vec', 'ALWAYS_NULLABLE'], + [['array_min'], 'DATETIMEV2', ['ARRAY_DATETIMEV2'], '', '', '', 'vec', 'ALWAYS_NULLABLE'], [['array_max'], 'TINYINT', ['ARRAY_TINYINT'], '', '', '', 'vec', 'ALWAYS_NULLABLE'], [['array_max'], 'SMALLINT', ['ARRAY_SMALLINT'], '', '', '', 'vec', 'ALWAYS_NULLABLE'], [['array_max'], 'INT', ['ARRAY_INT'], '', '', '', 'vec', 'ALWAYS_NULLABLE'], @@ -280,6 +284,10 @@ visible_functions = [ [['array_max'], 'FLOAT', ['ARRAY_FLOAT'], '', '', '', 'vec', 'ALWAYS_NULLABLE'], [['array_max'], 'DOUBLE', ['ARRAY_DOUBLE'], '', '', '', 'vec', 'ALWAYS_NULLABLE'], [['array_max'], 'DECIMALV2',['ARRAY_DECIMALV2'],'', '', '', 'vec', 'ALWAYS_NULLABLE'], + [['array_max'], 'DATE', ['ARRAY_DATE'], '', '', '', 'vec', 'ALWAYS_NULLABLE'], + [['array_max'], 'DATETIME', ['ARRAY_DATETIME'], '', '', '', 'vec', 'ALWAYS_NULLABLE'], + [['array_max'], 'DATEV2', ['ARRAY_DATEV2'], '', '', '', 'vec', 'ALWAYS_NULLABLE'], + [['array_max'], 'DATETIMEV2', ['ARRAY_DATETIMEV2'], '', '', '', 'vec', 'ALWAYS_NULLABLE'], [['array_sum'], 'BIGINT', ['ARRAY_TINYINT'], '', '', '', 'vec', 'ALWAYS_NULLABLE'], [['array_sum'], 'BIGINT', ['ARRAY_SMALLINT'], '', '', '', 'vec', 'ALWAYS_NULLABLE'], [['array_sum'], 'BIGINT', ['ARRAY_INT'], '', '', '', 'vec', 'ALWAYS_NULLABLE'], diff --git a/regression-test/data/query_p0/sql_functions/array_functions/test_array_aggregation_functions.out b/regression-test/data/query_p0/sql_functions/array_functions/test_array_aggregation_functions.out index 3564d7eb6e..6424664700 100644 --- a/regression-test/data/query_p0/sql_functions/array_functions/test_array_aggregation_functions.out +++ b/regression-test/data/query_p0/sql_functions/array_functions/test_array_aggregation_functions.out @@ -1,30 +1,31 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !select -- -1 1 100 1000 2147483648 9223372036854775808 0 1 100.0001 -2 1 \N \N \N \N \N 127 4.023 -3 -1 -32768 -2147483647 -9223372036854775808 -117341182548128045443221445 -9.999999 -1 -128.0001 -4 \N \N \N \N \N \N \N \N +1 1 100 1000 2147483648 9223372036854775808 0 1.0 100.0001 2022-08-31 2022-08-31T12:00 +2 1 \N \N \N \N \N 127.0 4.023 \N \N +3 -1 -32768 -2147483647 -9223372036854775808 -117341182548128045443221445 -9.999999 -1.0 -128.0001 \N \N +4 \N \N \N \N \N \N \N \N \N \N -- !select -- -1 3 101 1001 2147483649 9223372036854775808 9.999999 1.5 100.0005 -2 3 \N \N \N \N \N 128.1 4.023 -3 1 -32767 -50000 0 170141183460469231731687303715884105727 9.999999 1 127.0001 -4 \N \N \N \N \N \N \N \N +1 3 101 1001 2147483649 9223372036854775808 9.999999 1.5 100.0005 2022-10-15 2022-10-15T10:30 +2 3 \N \N \N \N \N 128.1 4.023 \N \N +3 1 -32767 -50000 0 170141183460469231731687303715884105727 9.999999 1.0 127.0001 \N \N +4 \N \N \N \N \N \N \N \N \N \N -- !select -- -1 2 100.5 1000.5 2147483648.5 9.2233720368547758e+18 4.9999995 1.25 100.00030000000001 -2 2 \N \N \N \N \N 127.55000305175781 4.023 -3 0 -32767.5 -1073766823.5 -4.6116860184273879e+18 8.5070591730175945e+37 0 0 -0.5 +1 2.0 100.5 1000.5 2.1474836485E9 9.223372036854776E18 4.9999995 1.25 100.00030000000001 +2 2.0 \N \N \N \N \N 127.55000305175781 4.023 +3 0.0 -32767.5 -1.0737668235E9 -4.6116860184273879E18 8.5070591730175945E37 0 0.0 -0.5 4 \N \N \N \N \N \N \N \N -- !select -- 1 6 201 2001 4294967297 9223372036854775808 9.999999 2.5 200.00060000000002 2 12 \N \N \N \N \N 255.10000610351562 4.023 -3 0 -65535 -2147533647 -9223372036854775808 170141183460351890549139175670440884282 0 0 -1 +3 0 -65535 -2147533647 -9223372036854775808 170141183460351890549139175670440884282 0 0.0 -1.0 4 \N \N \N \N \N \N \N \N -- !select -- -1 6 10100 1001000 4.6116860205748716e+18 9.2233720368547758e+18 0 1.5 10000.06000005 -2 36 \N \N \N \N \N 16268.700775146484 4.023 -3 -0 1073709056 107374182350000 -0 -1.9964567667389465e+64 -7766259631453241920 -0 -16256.02550001 +1 6.0 10100.0 1001000.0 4.6116860205748716E18 9.223372036854776E18 0 1.5 10000.06000005 +2 36.0 \N \N \N \N \N 16268.700775146484 4.023 +3 -0.0 1.073709056E9 1.0737418235E14 -0.0 -1.9964567667389465E64 -7766259631453241920 -0.0 -16256.02550001 4 \N \N \N \N \N \N \N \N + diff --git a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_aggregation_functions.groovy b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_aggregation_functions.groovy index 2a58e1be49..b652578ac6 100644 --- a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_aggregation_functions.groovy +++ b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_aggregation_functions.groovy @@ -44,13 +44,13 @@ suite("test_array_aggregation_functions") { "storage_format" = "V2" ) """ - sql """ INSERT INTO ${tableName} VALUES(1, [1, 2, 3], [100, 101], [1000, 1001], [2147483648, 2147483649], [9223372036854775808], [0.0, 9.999999], [1.0, 1.5], [100.0001, 100.0005], ['2022-08-31', '2022-09-01'], ['2022-08-31', '2022-09-01']) """ + sql """ INSERT INTO ${tableName} VALUES(1, [1, 2, 3], [100, 101], [1000, 1001], [2147483648, 2147483649], [9223372036854775808], [0.0, 9.999999], [1.0, 1.5], [100.0001, 100.0005], ['2022-10-15', '2022-08-31', '2022-09-01'], ['2022-10-15 10:30:00', '2022-08-31 12:00:00', '2022-09-01 09:00:00']) """ sql """ INSERT INTO ${tableName} VALUES(2, [1, 2, 3, NULL, 3, 2, 1], NULL, NULL, NULL, NULL, NULL, [127, 128.1], [NULL, 4.023], NULL, NULL) """ sql """ INSERT INTO ${tableName} VALUES(3, [-1, 0, 1], [-32767, -32768], [-50000, -2147483647], [-9223372036854775808, 0], [-117341182548128045443221445, 170141183460469231731687303715884105727], [-9.999999, 9.999999], [-1.0, 0.0, 1.0], [-128.0001, 127.0001], NULL, NULL) """ sql """ INSERT INTO ${tableName} VALUES(4, [], [], [], [], [], [], [], [], [], NULL) """ - qt_select "SELECT k1, array_min(a1), array_min(a2), array_min(a3), array_min(a4), array_min(a5), array_min(a6), array_min(a7), array_min(a8) from ${tableName} order by k1" - qt_select "SELECT k1, array_max(a1), array_max(a2), array_max(a3), array_max(a4), array_max(a5), array_max(a6), array_max(a7), array_max(a8) from ${tableName} order by k1" + qt_select "SELECT k1, array_min(a1), array_min(a2), array_min(a3), array_min(a4), array_min(a5), array_min(a6), array_min(a7), array_min(a8), array_min(a9), array_min(a10) from ${tableName} order by k1" + qt_select "SELECT k1, array_max(a1), array_max(a2), array_max(a3), array_max(a4), array_max(a5), array_max(a6), array_max(a7), array_max(a8), array_max(a9), array_max(a10) from ${tableName} order by k1" qt_select "SELECT k1, array_avg(a1), array_avg(a2), array_avg(a3), array_avg(a4), array_avg(a5), array_avg(a6), array_avg(a7), array_avg(a8) from ${tableName} order by k1" qt_select "SELECT k1, array_sum(a1), array_sum(a2), array_sum(a3), array_sum(a4), array_sum(a5), array_sum(a6), array_sum(a7), array_sum(a8) from ${tableName} order by k1" qt_select "SELECT k1, array_product(a1), array_product(a2), array_product(a3), array_product(a4), array_product(a5), array_product(a6), array_product(a7), array_product(a8) from ${tableName} order by k1" --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org