This is an automated email from the ASF dual-hosted git repository. yiguolei 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 99c0592157 [Feature](array-function) Support array_pushback function #17417 (#19988) 99c0592157 is described below commit 99c059215702f321632e987b244d27cb3a6a073d Author: jiawei liang <72728602+liangjiawei1...@users.noreply.github.com> AuthorDate: Mon Jun 12 16:51:12 2023 +0800 [Feature](array-function) Support array_pushback function #17417 (#19988) Implement array_pushback. mysql> select array_pushback([1, 2], 3); +--------------------------------+ | array_pushback(ARRAY(1, 2), 3) | +--------------------------------+ | [1, 2, 3] | +--------------------------------+ 1 row in set (0.01 sec) --- .../functions/array/function_array_pushback.cpp | 120 +++++++++++++++++++ .../functions/array/function_array_register.cpp | 2 + .../array-functions/array_pushback.md | 84 +++++++++++++ docs/sidebars.json | 1 + .../array-functions/array_pushback.md | 84 +++++++++++++ .../apache/doris/analysis/FunctionCallExpr.java | 2 + gensrc/script/doris_builtins_functions.py | 19 +++ .../array_functions/test_array_functions.out | 132 +++++++++++++++++++++ .../test_array_functions_by_literal.out | 33 ++++++ .../array_functions/test_array_with_scale_type.out | 20 ++++ .../array_functions/test_array_functions.groovy | 13 ++ .../test_array_functions_by_literal.groovy | 13 ++ .../test_array_with_scale_type.groovy | 6 + 13 files changed, 529 insertions(+) diff --git a/be/src/vec/functions/array/function_array_pushback.cpp b/be/src/vec/functions/array/function_array_pushback.cpp new file mode 100644 index 0000000000..b7b83f7f6d --- /dev/null +++ b/be/src/vec/functions/array/function_array_pushback.cpp @@ -0,0 +1,120 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// This file is copied from +// https://github.com/ClickHouse/ClickHouse/blob/master/src/Functions/array/arrayIndex.h +// and modified by Doris +#include <stddef.h> + +#include <memory> +#include <utility> + +#include "common/status.h" +#include "vec/aggregate_functions/aggregate_function.h" +#include "vec/columns/column.h" +#include "vec/columns/column_array.h" +#include "vec/columns/column_const.h" +#include "vec/columns/column_nullable.h" +#include "vec/core/block.h" +#include "vec/core/column_numbers.h" +#include "vec/core/column_with_type_and_name.h" +#include "vec/core/types.h" +#include "vec/data_types/data_type.h" +#include "vec/data_types/data_type_nullable.h" +#include "vec/functions/function.h" +#include "vec/functions/simple_function_factory.h" + +namespace doris { +class FunctionContext; +} // namespace doris + +namespace doris::vectorized { +class FunctionArrayPushback : public IFunction { +public: + static constexpr auto name = "array_pushback"; + + static FunctionPtr create() { return std::make_shared<FunctionArrayPushback>(); } + + String get_name() const override { return name; } + + bool is_variadic() const override { return false; } + + size_t get_number_of_arguments() const override { return 2; } + + bool use_default_implementation_for_nulls() const override { return false; } + + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { + return std::make_shared<DataTypeNullable>(remove_nullable(arguments[0])); + }; + + Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, + size_t result, size_t input_rows_count) override { + const auto& [src_column, src_const] = + unpack_if_const(block.get_by_position(arguments[0]).column); + const auto& [right_column, right_const] = + unpack_if_const(block.get_by_position(arguments[1]).column); + // extract src array column + const ColumnArray* array_column = nullptr; + const UInt8* array_null_map = nullptr; + if (src_column->is_nullable()) { + auto nullable_array = static_cast<const ColumnNullable*>(src_column.get()); + array_column = assert_cast<const ColumnArray*>(&nullable_array->get_nested_column()); + array_null_map = nullable_array->get_null_map_column().get_data().data(); + } else { + array_column = assert_cast<const ColumnArray*>(src_column.get()); + } + auto& src_nested_data_col = array_column->get_data(); + auto& src_offset_col = array_column->get_offsets(); + + auto result_col = block.get_by_position(result).type->create_column(); + auto result_nullable_col = assert_cast<ColumnNullable*>(result_col.get()); + auto& result_null_map = result_nullable_col->get_null_map_data(); + auto result_array_col = + assert_cast<ColumnArray*>(result_nullable_col->get_nested_column_ptr().get()); + + auto& result_nested_data_col = result_array_col->get_data(); + auto& result_offset_col = result_array_col->get_offsets(); + + result_null_map.resize(input_rows_count); + result_offset_col.resize(input_rows_count); + result_nested_data_col.reserve(src_nested_data_col.size() + input_rows_count); + + size_t off = 0; + for (size_t i = 0; i < input_rows_count; ++i) { + if (array_null_map && array_null_map[i]) { + result_null_map[i] = 1; + result_offset_col[i] = off; + continue; + } + + size_t src_off = src_offset_col[index_check_const(i, src_const) - 1]; + size_t src_len = src_offset_col[index_check_const(i, src_const)] - src_off; + result_nested_data_col.insert_range_from(src_nested_data_col, src_off, src_len); + + result_nested_data_col.insert((*right_column)[index_check_const(i, right_const)]); + off += src_len + 1; + result_null_map[i] = 0; + result_offset_col[i] = off; + } + block.replace_by_position(result, std::move(result_col)); + return Status::OK(); + } +}; + +void register_function_array_pushback(SimpleFunctionFactory& factory) { + factory.register_function<FunctionArrayPushback>(); +} +} // namespace doris::vectorized \ No newline at end of file diff --git a/be/src/vec/functions/array/function_array_register.cpp b/be/src/vec/functions/array/function_array_register.cpp index adb6442f76..c77bc0686d 100644 --- a/be/src/vec/functions/array/function_array_register.cpp +++ b/be/src/vec/functions/array/function_array_register.cpp @@ -50,6 +50,7 @@ void register_function_array_apply(SimpleFunctionFactory&); void register_function_array_concat(SimpleFunctionFactory&); void register_function_array_zip(SimpleFunctionFactory&); void register_function_array_pushfront(SimpleFunctionFactory& factory); +void register_function_array_pushback(SimpleFunctionFactory& factory); void register_function_array_first_or_last_index(SimpleFunctionFactory& factory); void register_function_array_cum_sum(SimpleFunctionFactory& factory); void register_function_array_count(SimpleFunctionFactory&); @@ -83,6 +84,7 @@ void register_function_array(SimpleFunctionFactory& factory) { register_function_array_concat(factory); register_function_array_zip(factory); register_function_array_pushfront(factory); + register_function_array_pushback(factory); register_function_array_first_or_last_index(factory); register_function_array_cum_sum(factory); register_function_array_count(factory); diff --git a/docs/en/docs/sql-manual/sql-functions/array-functions/array_pushback.md b/docs/en/docs/sql-manual/sql-functions/array-functions/array_pushback.md new file mode 100644 index 0000000000..04489f5676 --- /dev/null +++ b/docs/en/docs/sql-manual/sql-functions/array-functions/array_pushback.md @@ -0,0 +1,84 @@ +--- +{ + "title": "array_pushback", + "language": "en" +} +--- + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +## array_pushback + +<version since="1.2.3"> + +array_pushback + +</version> + +### description + +#### Syntax + +`Array<T> array_pushback(Array<T> arr, T value)` + +Add the value to the end of the array. + +#### Returned value + +The array after adding the value. + +Type: Array. + +### notice + +`Only supported in vectorized engine` + +### example + +``` +mysql> select array_pushback([1, 2], 3); ++---------------------------------+ +| array_pushback(ARRAY(1, 2), 3) | ++---------------------------------+ +| [1, 2, 3] | ++---------------------------------+ + +mysql> select col3, array_pushback(col3, 6) from array_test; ++-----------+----------------------------+ +| col3 | array_pushback(`col3`, 6) | ++-----------+----------------------------+ +| [3, 4, 5] | [3, 4, 5, 6] | +| [NULL] | [NULL, 6] | +| NULL | NULL | +| [] | [6] | ++-----------+----------------------------+ + +mysql> select col1, col3, array_pushback(col3, col1) from array_test; ++------+-----------+---------------------------------+ +| col1 | col3 | array_pushback(`col3`, `col1`) | ++------+-----------+---------------------------------+ +| 0 | [3, 4, 5] | [3, 4, 5, 0] | +| 1 | [NULL] | [NULL, 1] | +| 2 | NULL | NULL | +| 3 | [] | [3] | ++------+-----------+---------------------------------+ +``` + +### keywords + +ARRAY,PUSHBACK,ARRAY_PUSHBACK \ No newline at end of file diff --git a/docs/sidebars.json b/docs/sidebars.json index b7a471ee60..cf04970c65 100644 --- a/docs/sidebars.json +++ b/docs/sidebars.json @@ -294,6 +294,7 @@ "sql-manual/sql-functions/array-functions/array_popback", "sql-manual/sql-functions/array-functions/array_popfront", "sql-manual/sql-functions/array-functions/array_pushfront", + "sql-manual/sql-functions/array-functions/array_pushback", "sql-manual/sql-functions/array-functions/array_compact", "sql-manual/sql-functions/array-functions/array_concat", "sql-manual/sql-functions/array-functions/array_zip", diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/array-functions/array_pushback.md b/docs/zh-CN/docs/sql-manual/sql-functions/array-functions/array_pushback.md new file mode 100644 index 0000000000..dc3337e24f --- /dev/null +++ b/docs/zh-CN/docs/sql-manual/sql-functions/array-functions/array_pushback.md @@ -0,0 +1,84 @@ +--- +{ + "title": "array_pushback", + "language": "zh-CN" +} +--- + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +## array_pushback + +<version since="1.2.3"> + +array_pushback + +</version> + +### description + +#### Syntax + +`Array<T> array_pushback(Array<T> arr, T value)` + +将value添加到数组的尾部. + +#### Returned value + +返回添加value后的数组 + +类型: Array. + +### notice + +`只支持在向量化引擎中使用` + +### example + +``` +mysql> select array_pushback([1, 2], 3); ++---------------------------------+ +| array_pushback(ARRAY(1, 2), 3) | ++---------------------------------+ +| [1, 2, 3] | ++---------------------------------+ + +mysql> select col3, array_pushback(col3, 6) from array_test; ++-----------+----------------------------+ +| col3 | array_pushback(`col3`, 6) | ++-----------+----------------------------+ +| [3, 4, 5] | [3, 4, 5, 6] | +| [NULL] | [NULL, 6] | +| NULL | NULL | +| [] | [6] | ++-----------+----------------------------+ + +mysql> select col1, col3, array_pushback(col3, col1) from array_test; ++------+-----------+---------------------------------+ +| col1 | col3 | array_pushback(`col3`, `col1`) | ++------+-----------+---------------------------------+ +| 0 | [3, 4, 5] | [3, 4, 5, 0] | +| 1 | [NULL] | [NULL, 1] | +| 2 | NULL | NULL | +| 3 | [] | [3] | ++------+-----------+---------------------------------+ +``` + +### keywords + +ARRAY,PUSHBACK,ARRAY_PUSHBACK \ No newline at end of file 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 4267d3586f..e037a92a18 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 @@ -1686,6 +1686,7 @@ public class FunctionCallExpr extends Expr { || fnName.getFunction().equalsIgnoreCase("array_popback") || fnName.getFunction().equalsIgnoreCase("array_popfront") || fnName.getFunction().equalsIgnoreCase("array_pushfront") + || fnName.getFunction().equalsIgnoreCase("array_pushback") || fnName.getFunction().equalsIgnoreCase("array_cum_sum") || fnName.getFunction().equalsIgnoreCase("reverse") || fnName.getFunction().equalsIgnoreCase("%element_slice%") @@ -1841,6 +1842,7 @@ public class FunctionCallExpr extends Expr { || fnName.getFunction().equalsIgnoreCase("array_popback") || fnName.getFunction().equalsIgnoreCase("array_popfront") || fnName.getFunction().equalsIgnoreCase("array_pushfront") + || fnName.getFunction().equalsIgnoreCase("array_pushback") || fnName.getFunction().equalsIgnoreCase("reverse") || fnName.getFunction().equalsIgnoreCase("%element_slice%") || fnName.getFunction().equalsIgnoreCase("array_shuffle") diff --git a/gensrc/script/doris_builtins_functions.py b/gensrc/script/doris_builtins_functions.py index 61eb7c39ab..6b9b9458ae 100644 --- a/gensrc/script/doris_builtins_functions.py +++ b/gensrc/script/doris_builtins_functions.py @@ -757,6 +757,25 @@ visible_functions = { [['array_pushfront'], 'ARRAY_VARCHAR', ['ARRAY_VARCHAR', 'VARCHAR'], 'ALWAYS_NULLABLE'], [['array_pushfront'], 'ARRAY_STRING', ['ARRAY_STRING', 'STRING'], 'ALWAYS_NULLABLE'], + [['array_pushback'], 'ARRAY_BOOLEAN', ['ARRAY_BOOLEAN', 'BOOLEAN'], 'ALWAYS_NULLABLE'], + [['array_pushback'], 'ARRAY_TINYINT', ['ARRAY_TINYINT', 'TINYINT'], 'ALWAYS_NULLABLE'], + [['array_pushback'], 'ARRAY_SMALLINT', ['ARRAY_SMALLINT', 'SMALLINT'], 'ALWAYS_NULLABLE'], + [['array_pushback'], 'ARRAY_INT', ['ARRAY_INT', 'INT'], 'ALWAYS_NULLABLE'], + [['array_pushback'], 'ARRAY_BIGINT', ['ARRAY_BIGINT', 'BIGINT'], 'ALWAYS_NULLABLE'], + [['array_pushback'], 'ARRAY_LARGEINT', ['ARRAY_LARGEINT', 'LARGEINT'], 'ALWAYS_NULLABLE'], + [['array_pushback'], 'ARRAY_DATETIME', ['ARRAY_DATETIME', 'DATETIME'], 'ALWAYS_NULLABLE'], + [['array_pushback'], 'ARRAY_DATE', ['ARRAY_DATE', 'DATE'], 'ALWAYS_NULLABLE'], + [['array_pushback'], 'ARRAY_DATETIMEV2', ['ARRAY_DATETIMEV2', 'DATETIMEV2'], 'ALWAYS_NULLABLE'], + [['array_pushback'], 'ARRAY_DATEV2', ['ARRAY_DATEV2', 'DATEV2'], 'ALWAYS_NULLABLE'], + [['array_pushback'], 'ARRAY_FLOAT', ['ARRAY_FLOAT', 'FLOAT'], 'ALWAYS_NULLABLE'], + [['array_pushback'], 'ARRAY_DOUBLE', ['ARRAY_DOUBLE', 'DOUBLE'], 'ALWAYS_NULLABLE'], + [['array_pushback'], 'ARRAY_DECIMALV2', ['ARRAY_DECIMALV2', 'DECIMALV2'], 'ALWAYS_NULLABLE'], + [['array_pushback'], 'ARRAY_DECIMAL32', ['ARRAY_DECIMAL32', 'DECIMAL32'], 'ALWAYS_NULLABLE'], + [['array_pushback'], 'ARRAY_DECIMAL64', ['ARRAY_DECIMAL64', 'DECIMAL64'], 'ALWAYS_NULLABLE'], + [['array_pushback'], 'ARRAY_DECIMAL128', ['ARRAY_DECIMAL128', 'DECIMAL128'], 'ALWAYS_NULLABLE'], + [['array_pushback'], 'ARRAY_VARCHAR', ['ARRAY_VARCHAR', 'VARCHAR'], 'ALWAYS_NULLABLE'], + [['array_pushback'], 'ARRAY_STRING', ['ARRAY_STRING', 'STRING'], 'ALWAYS_NULLABLE'], + [['array_with_constant'], 'ARRAY_BOOLEAN', ['BIGINT', 'BOOLEAN'], 'ALWAYS_NOT_NULLABLE'], [['array_with_constant'], 'ARRAY_TINYINT', ['BIGINT', 'TINYINT'], 'ALWAYS_NOT_NULLABLE'], [['array_with_constant'], 'ARRAY_SMALLINT', ['BIGINT','SMALLINT'], 'ALWAYS_NOT_NULLABLE'], diff --git a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions.out b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions.out index fc2b267878..277cc4e883 100644 --- a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions.out +++ b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions.out @@ -1556,6 +1556,138 @@ 8 \N 9 \N +-- !select -- +1 [1, 2, 3, 1] +2 [4, 2] +3 [3] +4 [1, 2, 3, 4, 5, 4, 3, 2, 1, 4] +5 [5] +6 [1, 2, 3, 4, 5, 4, 3, 2, 1, 6] +7 [8, 9, NULL, 10, NULL, 7] +8 [1, 2, 3, 3, 4, 4, NULL, 8] +9 [1, 2, 3, 9] + +-- !select -- +1 [1, 2, 3, 1] +2 [4, 1] +3 [1] +4 [1, 2, 3, 4, 5, 4, 3, 2, 1, 1] +5 [1] +6 [1, 2, 3, 4, 5, 4, 3, 2, 1, 1] +7 [8, 9, NULL, 10, NULL, 1] +8 [1, 2, 3, 3, 4, 4, NULL, 1] +9 [1, 2, 3, 1] + +-- !select -- +1 ["a", "b", "", "a"] +2 \N +3 ["a"] +4 ["a"] +5 ["a", "b", "c", "d", "c", "b", "a", "a"] +6 ["a", "b", "c", "d", "c", "b", "a", "a"] +7 ["f", NULL, "g", NULL, "h", "a"] +8 ["a", "b", "b", "b", "a"] +9 ["a", "b", "", "a"] + +-- !select -- +1 ["a", "b", "", NULL] +2 \N +3 [NULL] +4 [NULL] +5 ["a", "b", "c", "d", "c", "b", "a", NULL] +6 ["a", "b", "c", "d", "c", "b", "a", NULL] +7 ["f", NULL, "g", NULL, "h", NULL] +8 ["a", "b", "b", "b", NULL] +9 ["a", "b", "", NULL] + +-- !select -- +1 [1, 2, NULL] +2 [5, NULL] +3 \N +4 [NULL] +5 \N +6 \N +7 \N +8 [1, 2, 2, 3, NULL] +9 [1, 2, NULL] + +-- !select -- +1 ["hi", "hi"] +2 ["hi2", "hi"] +3 ["hi3", "hi"] +4 \N +5 \N +6 \N +7 \N +8 ["hi", "hi", "hello", "hi"] +9 ["hi", "hi"] + +-- !select -- +1 ["hi", "hi222"] +2 ["hi2", "hi222"] +3 ["hi3", "hi222"] +4 \N +5 \N +6 \N +7 \N +8 ["hi", "hi", "hello", "hi222"] +9 ["hi", "hi222"] + +-- !select -- +1 [2015-03-13, NULL] +2 \N +3 \N +4 \N +5 \N +6 \N +7 \N +8 [2015-03-13, NULL] +9 [2015-03-13, 2015-03-13, 2015-03-14, NULL] + +-- !select -- +1 [2023-02-05, 2023-02-06, 2023-03-05] +2 [2023-01-05, 2023-01-06, 2023-03-05] +3 \N +4 \N +5 \N +6 \N +7 \N +8 \N +9 \N + +-- !select -- +1 [2022-10-15 10:30:00.999, 2022-08-31 12:00:00.999, 2023-03-08 10:30:00.999] +2 [2022-11-15 10:30:00.999, 2022-01-31 12:00:00.999, 2023-03-08 10:30:00.999] +3 \N +4 \N +5 \N +6 \N +7 \N +8 \N +9 \N + +-- !select -- +1 [2022-10-15 10:30:00.999, 2022-08-31 12:00:00.999, NULL] +2 [2022-11-15 10:30:00.999, 2022-01-31 12:00:00.999, NULL] +3 \N +4 \N +5 \N +6 \N +7 \N +8 \N +9 \N + +-- !select -- +1 [111.111, 222.222, NULL] +2 [333.333, 444.444, NULL] +3 \N +4 \N +5 \N +6 \N +7 \N +8 \N +9 \N + -- !select -- [1, 2, 3] 1,2,3 [4] 4 diff --git a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out index 804e8472d1..cdec471b73 100644 --- a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out +++ b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out @@ -842,6 +842,39 @@ _ -- !sql -- [333.333, 111.111, 222.222] +-- !sql -- +[1, 2, 3, 6] + +-- !sql -- +[1, 2, 3, NULL] + +-- !sql -- +\N + +-- !sql -- +[1.111, 2.222, 3.333, 9.999] + +-- !sql -- +["aaa", "bbb", "ccc", "dddd"] + +-- !sql -- +[12.990, 34.990, 999.280] + +-- !sql -- +[2023-03-05, 2023-03-04, 2023-02-05] + +-- !sql -- +[2023-03-05 12:23:24.999, 2023-03-05 15:23:23.997, 2023-03-08 16:23:54.999] + +-- !sql -- +[111.111, 222.222, 333.333] + +-- !sql -- +[NULL, NULL, NULL] + +-- !sql -- +[NULL, NULL, NULL, NULL, 80] + -- !sql -- [0, 2, 129] diff --git a/regression-test/data/query_p0/sql_functions/array_functions/test_array_with_scale_type.out b/regression-test/data/query_p0/sql_functions/array_functions/test_array_with_scale_type.out index 89098e104e..e2b4a2a2af 100644 --- a/regression-test/data/query_p0/sql_functions/array_functions/test_array_with_scale_type.out +++ b/regression-test/data/query_p0/sql_functions/array_functions/test_array_with_scale_type.out @@ -162,6 +162,26 @@ 22.679 [22.679, 33.679] [22.679, 22.679, 33.679] 23.679 [23.679, 34.679] [23.679, 23.679, 34.679] +-- !select -- +[2022-12-02 22:23:24.999, 2022-12-02 22:23:24.999] +[2022-12-02 22:23:24.999, 2022-12-02 22:23:24.999] + +-- !select -- +[2022-12-01 22:23:24.999, 2022-12-01 23:23:24.999, 2023-03-08 23:23:23.997] +[2022-12-02 22:23:24.999, 2022-12-02 23:23:24.999, 2023-03-08 23:23:23.997] + +-- !select -- +2022-12-01T22:23:24.999 [2022-12-01 22:23:24.999, 2022-12-01 23:23:24.999] [2022-12-01 22:23:24.999, 2022-12-01 23:23:24.999, 2022-12-01 22:23:24.999] +2022-12-02T22:23:24.999 [2022-12-02 22:23:24.999, 2022-12-02 23:23:24.999] [2022-12-02 22:23:24.999, 2022-12-02 23:23:24.999, 2022-12-02 22:23:24.999] + +-- !select -- +[22.679, 33.679, 25.990] +[23.679, 34.679, 25.990] + +-- !select -- +22.679 [22.679, 33.679] [22.679, 33.679, 22.679] +23.679 [23.679, 34.679] [23.679, 34.679, 23.679] + -- !select -- [23, 11] diff --git a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy index 6ccd9f73c1..25f246b612 100644 --- a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy +++ b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy @@ -225,6 +225,19 @@ suite("test_array_functions") { qt_select "SELECT k1, array_pushfront(k10, null) FROM ${tableName} ORDER BY k1" qt_select "SELECT k1, array_pushfront(k12, null) FROM ${tableName} ORDER BY k1" + qt_select "SELECT k1, array_pushback(k2, k1) FROM ${tableName} ORDER BY k1" + qt_select "SELECT k1, array_pushback(k2, 1) FROM ${tableName} ORDER BY k1" + qt_select "SELECT k1, array_pushback(k3, 'a') FROM ${tableName} ORDER BY k1" + qt_select "SELECT k1, array_pushback(k3, null) FROM ${tableName} ORDER BY k1" + qt_select "SELECT k1, array_pushback(k4, null) FROM ${tableName} ORDER BY k1" + qt_select "SELECT k1, array_pushback(k5, 'hi') FROM ${tableName} ORDER BY k1" + qt_select "SELECT k1, array_pushback(k5, 'hi222') FROM ${tableName} ORDER BY k1" + qt_select "SELECT k1, array_pushback(k6, null) from ${tableName} ORDER BY k1" + qt_select "SELECT k1, array_pushback(k8, cast('2023-03-05' as datev2)) FROM ${tableName} ORDER BY k1" + qt_select "SELECT k1, array_pushback(k10, cast('2023-03-08 10:30:00.999' as datetimev2(3))) FROM ${tableName} ORDER BY k1" + qt_select "SELECT k1, array_pushback(k10, null) FROM ${tableName} ORDER BY k1" + qt_select "SELECT k1, array_pushback(k12, null) FROM ${tableName} ORDER BY k1" + qt_select "select k2, bitmap_to_string(bitmap_from_array(k2)) from ${tableName} order by k1;" def tableName3 = "tbl_test_array_set" diff --git a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy index 584750d1ca..c29bf53103 100644 --- a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy +++ b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy @@ -342,6 +342,19 @@ suite("test_array_functions_by_literal") { qt_sql "select array_pushfront(array(cast ('2023-03-05 12:23:24.999' as datetimev2(3)),cast ('2023-03-05 15:23:23.997' as datetimev2(3))), cast ('2023-03-08 16:23:54.999' as datetimev2(3)))" qt_sql "select array_pushfront(array(cast (111.111 as decimalv3(6,3)),cast (222.222 as decimalv3(6,3))), cast (333.333 as decimalv3(6,3)))" + // array_pushback + qt_sql "select array_pushback([1, 2, 3], 6)" + qt_sql "select array_pushback([1, 2, 3], null)" + qt_sql "select array_pushback(null, 6)" + qt_sql "select array_pushback([1.111, 2.222, 3.333], 9.999)" + qt_sql "select array_pushback(['aaa', 'bbb', 'ccc'], 'dddd')" + qt_sql "select array_pushback(array(cast (12.99 as decimal(10,3)), cast (34.99 as decimal(10,3))), cast (999.28 as decimal(10,3)))" + qt_sql "select array_pushback(array(cast ('2023-03-05' as datev2), cast ('2023-03-04' as datev2)), cast ('2023-02-05' as datev2))" + qt_sql "select array_pushback(array(cast ('2023-03-05 12:23:24.999' as datetimev2(3)),cast ('2023-03-05 15:23:23.997' as datetimev2(3))), cast ('2023-03-08 16:23:54.999' as datetimev2(3)))" + qt_sql "select array_pushback(array(cast (111.111 as decimalv3(6,3)),cast (222.222 as decimalv3(6,3))), cast (333.333 as decimalv3(6,3)))" + qt_sql "select array_pushback([null,null], null)" + qt_sql "select array_pushback([null,null,null,null], 80)" + // array_cum_sum qt_sql "select array_cum_sum([0, 2, 127])" qt_sql "select array_cum_sum([254, 4, 0])" diff --git a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_with_scale_type.groovy b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_with_scale_type.groovy index 03a07c257d..53a37100f0 100644 --- a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_with_scale_type.groovy +++ b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_with_scale_type.groovy @@ -94,6 +94,12 @@ suite("test_array_with_scale_type") { qt_select "select array_pushfront(c_array_decimal, cast (25.99 as decimalv3(10,3))) from ${tableName}" qt_select "select c_decimal, c_array_decimal, array_pushfront(c_array_decimal, c_decimal) from ${tableName}" + qt_select "select array_pushback(array(cast ('2022-12-02 22:23:24.999999' as datetimev2(3))),cast ('2022-12-02 22:23:23.997799' as datetimev2(3))) from ${tableName}" + qt_select "select array_pushback(c_array_datetimev2, cast ('2023-03-08 23:23:23.997799' as datetimev2(3))) from ${tableName}" + qt_select "select c_datetimev2, c_array_datetimev2, array_pushback(c_array_datetimev2, c_datetimev2) from ${tableName}" + qt_select "select array_pushback(c_array_decimal, cast (25.99 as decimalv3(10,3))) from ${tableName}" + qt_select "select c_decimal, c_array_decimal, array_pushback(c_array_decimal, c_decimal) from ${tableName}" + qt_select "select array_cum_sum(array(cast (22.99 as decimal), cast (-11.99 as decimal)))" qt_select "select array_cum_sum(array(cast (22.99 as decimal(10,3)), cast (-11.99 as decimal(10,3))))" qt_select "select array_cum_sum(array(cast (22.99 as decimal(10,6)), cast (-11.991 as decimal(10,6))))" --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org