[Enhance](array function) add support for DecimalV3 for array_enumerate_uniq() (#17724)

This commit is contained in:
bobhan1
2023-05-30 13:09:19 +08:00
committed by GitHub
parent c7b8c83a7f
commit bb12a1cb49
5 changed files with 23 additions and 1 deletions

View File

@ -181,6 +181,12 @@ public:
_execute_number<ColumnDateTime>(data_columns, *offsets, null_map, dst_values);
} else if (which.is_date_v2()) {
_execute_number<ColumnDateV2>(data_columns, *offsets, null_map, dst_values);
} else if (which.is_decimal32()) {
_execute_number<ColumnDecimal32>(data_columns, *offsets, null_map, dst_values);
} else if (which.is_decimal64()) {
_execute_number<ColumnDecimal64>(data_columns, *offsets, null_map, dst_values);
} else if (which.is_decimal128i()) {
_execute_number<ColumnDecimal128I>(data_columns, *offsets, null_map, dst_values);
} else if (which.is_date_time_v2()) {
_execute_number<ColumnDateTimeV2>(data_columns, *offsets, null_map, dst_values);
} else if (which.is_decimal128()) {

View File

@ -692,6 +692,17 @@
8 \N
9 \N
-- !select --
1 [1, 1]
2 [1, 1]
3 \N
4 \N
5 \N
6 \N
7 \N
8 \N
9 \N
-- !select_array_shuffle1 --
1 [1, 2, 3] 6 6 [3, 2, 1] [3, 2, 1]
2 [4] 4 4 [4] [4]

View File

@ -779,6 +779,9 @@ _
-- !sql --
[1, 1, 2]
-- !sql --
[1, 1, 2, 1, 3]
-- !sql --
[1, 1, 1, 1, 1]

View File

@ -115,6 +115,7 @@ suite("test_array_functions") {
qt_select "SELECT k1, array_enumerate_uniq(k7) from ${tableName} ORDER BY k1"
qt_select "SELECT k1, array_enumerate_uniq(k8) from ${tableName} ORDER BY k1"
qt_select "SELECT k1, array_enumerate_uniq(k10) from ${tableName} ORDER BY k1"
qt_select "SELECT k1, array_enumerate_uniq(k12) from ${tableName} ORDER BY k1"
qt_select_array_shuffle1 "SELECT k1, k2, array_sum(k2), array_sum(array_shuffle(k2)), array_shuffle(k2, 0), shuffle(k2, 0) from ${tableName} ORDER BY k1"
qt_select_array_shuffle2 "SELECT k1, k5, array_size(k5), array_size(array_shuffle(k5)), array_shuffle(k5, 0), shuffle(k5, 0) from ${tableName} ORDER BY k1"
qt_select_array_shuffle3 "SELECT k1, k6, array_size(k6), array_size(array_shuffle(k6)), array_shuffle(k6, 0), shuffle(k6, 0) from ${tableName} ORDER BY k1"

View File

@ -316,13 +316,14 @@ suite("test_array_functions_by_literal") {
qt_sql "select array_enumerate_uniq(['11', '22', '33', '11', '33', '22'])"
qt_sql "select array_enumerate_uniq(array(cast (24.99 as decimal(10,3)), cast (25.99 as decimal(10,3)), cast (24.99 as decimal(10,3))))"
qt_sql "select array_enumerate_uniq(array(cast ('2023-02-06 22:07:34.999' as datetimev2(3)), cast ('2023-02-04 23:07:34.999' as datetimev2(3)), cast ('2023-02-06 22:07:34.999' as datetimev2(3))))"
qt_sql "select array_enumerate_uniq(array(cast (384.2933 as decimalv3(7, 4)), cast (984.1913 as decimalv3(7, 4)), cast (384.2933 as decimalv3(7, 4)), cast (722.9333 as decimalv3(7, 4)), cast (384.2933 as decimalv3(7, 4))))"
qt_sql "select array_enumerate_uniq([1, 2, 3, 4, 5], [1, 2, 3, 4, 5])"
qt_sql "select array_enumerate_uniq([1, 1, 1, 1, 1], [1, 1, 1, 1, 1])"
qt_sql "select array_enumerate_uniq([1, 1, 1, 1, 1], [1, 1, 1, 1, 1])"
qt_sql "select array_enumerate_uniq([1, 1, 2, 2, 1, 2], [1, 2, 1, 2, 2, 1])"
qt_sql "select array_enumerate_uniq([1, null, 1, null], [null, 1, null, 1])"
qt_sql "select array_enumerate_uniq([1, 1, 1, 1, 1, 1], [2, 1, 2, 1, 2, 1], [3, 1, 3, 1, 3, 1])"
qt_sql "select array_enumerate_uniq([1, 3, 1], [2.0, 5.0, 2.0], ['3', '8', '3'])"
qt_sql "select array_enumerate_uniq([1, 3, 1], [2.0, 5.0, 2.0], ['3', '8', '3'], array(cast (34.9876 as decimalv3(6, 4)), cast (89.9865 as decimalv3(6, 4)), cast (34.9876 as decimalv3(6, 4))))"
// array_pushfront
qt_sql "select array_pushfront([1, 2, 3], 6)"