This is an automated email from the ASF dual-hosted git repository.

dataroaring 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 c302fa2564 [Feature](array-function) Support array_pushfront function 
(#17584)
c302fa2564 is described below

commit c302fa2564b767f4a28bc2a6546a069a34c3dd3a
Author: gitccl <60637740+git...@users.noreply.github.com>
AuthorDate: Mon Mar 13 14:26:02 2023 +0800

    [Feature](array-function) Support array_pushfront function (#17584)
---
 be/src/vec/CMakeLists.txt                          |   1 +
 .../functions/array/function_array_pushfront.cpp   | 113 +++++++++++++++++++
 .../functions/array/function_array_register.cpp    |   2 +
 .../array-functions/array_pushfront.md             |  85 +++++++++++++++
 docs/sidebars.json                                 |   1 +
 .../array-functions/array_pushfront.md             |  85 +++++++++++++++
 .../apache/doris/analysis/FunctionCallExpr.java    |   1 +
 gensrc/script/doris_builtins_functions.py          |  19 ++++
 .../array_functions/test_array_functions.out       | 121 +++++++++++++++++++++
 .../test_array_functions_by_literal.out            |  24 ++++
 .../array_functions/test_array_with_scale_type.out |  20 ++++
 .../array_functions/test_array_functions.groovy    |  12 ++
 .../test_array_functions_by_literal.groovy         |  10 ++
 .../test_array_with_scale_type.groovy              |   6 +
 14 files changed, 500 insertions(+)

diff --git a/be/src/vec/CMakeLists.txt b/be/src/vec/CMakeLists.txt
index 12343adf80..d280bce0e9 100644
--- a/be/src/vec/CMakeLists.txt
+++ b/be/src/vec/CMakeLists.txt
@@ -182,6 +182,7 @@ set(VEC_FILES
   functions/array/function_array_with_constant.cpp
   functions/array/function_array_apply.cpp
   functions/array/function_array_concat.cpp
+  functions/array/function_array_pushfront.cpp
   exprs/table_function/vexplode_json_array.cpp
   functions/math.cpp
   functions/function_bitmap.cpp
diff --git a/be/src/vec/functions/array/function_array_pushfront.cpp 
b/be/src/vec/functions/array/function_array_pushfront.cpp
new file mode 100644
index 0000000000..5da81776a7
--- /dev/null
+++ b/be/src/vec/functions/array/function_array_pushfront.cpp
@@ -0,0 +1,113 @@
+// 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 "vec/columns/column.h"
+#include "vec/columns/column_array.h"
+#include "vec/columns/column_const.h"
+#include "vec/columns/column_nullable.h"
+#include "vec/data_types/data_type_nullable.h"
+#include "vec/functions/array/function_array_utils.h"
+#include "vec/functions/function.h"
+#include "vec/functions/simple_function_factory.h"
+
+namespace doris::vectorized {
+
+class FunctionArrayPushfront : public IFunction {
+public:
+    static constexpr auto name = "array_pushfront";
+
+    static FunctionPtr create() { return 
std::make_shared<FunctionArrayPushfront>(); }
+
+    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 {
+        // the type of arguments[0] could be Array(Nullable(xxx)) or 
Nullable(Array(Nullable(xxx))),
+        // and we always return Nullable(Array(Nullable(xxx)))
+        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 {
+        auto src_column =
+                
block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
+        // 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 = static_cast<const 
ColumnArray*>(&nullable_array->get_nested_column());
+            array_null_map = 
nullable_array->get_null_map_column().get_data().data();
+        } else {
+            array_column = static_cast<const ColumnArray*>(src_column.get());
+        }
+        auto& src_nested_data_col = array_column->get_data();
+        auto& src_offset_col = array_column->get_offsets();
+
+        auto right_column =
+                
block.get_by_position(arguments[1]).column->convert_to_full_column_if_const();
+
+        // prepare dst nullable array column
+        auto result_col = block.get_by_position(result).type->create_column();
+        auto result_nullable_col = 
static_cast<ColumnNullable*>(result_col.get());
+        auto& result_null_map = result_nullable_col->get_null_map_data();
+        auto result_array_col =
+                
static_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 length = src_offset_col[i] - src_offset_col[i - 1];
+            result_nested_data_col.insert((*right_column)[i]);
+            result_nested_data_col.insert_range_from(src_nested_data_col, 
src_offset_col[i - 1],
+                                                     length);
+
+            off += length + 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_pushfront(SimpleFunctionFactory& factory) {
+    factory.register_function<FunctionArrayPushfront>();
+}
+
+} // namespace doris::vectorized
diff --git a/be/src/vec/functions/array/function_array_register.cpp 
b/be/src/vec/functions/array/function_array_register.cpp
index cd29ee6bac..315e6bec9c 100644
--- a/be/src/vec/functions/array/function_array_register.cpp
+++ b/be/src/vec/functions/array/function_array_register.cpp
@@ -45,6 +45,7 @@ void 
register_function_array_with_constant(SimpleFunctionFactory&);
 void register_function_array_constructor(SimpleFunctionFactory&);
 void register_function_array_apply(SimpleFunctionFactory&);
 void register_function_array_concat(SimpleFunctionFactory&);
+void register_function_array_pushfront(SimpleFunctionFactory& factory);
 
 void register_function_array(SimpleFunctionFactory& factory) {
     register_function_array_element(factory);
@@ -70,6 +71,7 @@ void register_function_array(SimpleFunctionFactory& factory) {
     register_function_array_constructor(factory);
     register_function_array_apply(factory);
     register_function_array_concat(factory);
+    register_function_array_pushfront(factory);
 }
 
 } // namespace doris::vectorized
diff --git 
a/docs/en/docs/sql-manual/sql-functions/array-functions/array_pushfront.md 
b/docs/en/docs/sql-manual/sql-functions/array-functions/array_pushfront.md
new file mode 100644
index 0000000000..65f52f8349
--- /dev/null
+++ b/docs/en/docs/sql-manual/sql-functions/array-functions/array_pushfront.md
@@ -0,0 +1,85 @@
+---
+{
+    "title": "array_pushfront",
+    "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_pushfront
+
+<version since="1.2.3">
+
+array_pushfront
+
+</version>
+
+### description
+
+#### Syntax
+
+```sql
+Array<T> array_pushfront(Array<T> arr, T value)
+```
+Add the value to the beginning of the array.
+
+#### Returned value
+
+The array after adding the value.
+
+Type: Array.
+
+### notice
+
+`Only supported in vectorized engine`
+
+### example
+
+```
+mysql> select array_pushfront([1, 2], 3);
++---------------------------------+
+| array_pushfront(ARRAY(1, 2), 3) |
++---------------------------------+
+| [3, 1, 2]                       |
++---------------------------------+
+
+mysql> select col3, array_pushfront(col3, 6) from array_test;
++-----------+----------------------------+
+| col3      | array_pushfront(`col3`, 6) |
++-----------+----------------------------+
+| [3, 4, 5] | [6, 3, 4, 5]               |
+| [NULL]    | [6, NULL]                  |
+| NULL      | NULL                       |
+| []        | [6]                        |
++-----------+----------------------------+
+
+mysql> select col1, col3, array_pushfront(col3, col1) from array_test;
++------+-----------+---------------------------------+
+| col1 | col3      | array_pushfront(`col3`, `col1`) |
++------+-----------+---------------------------------+
+|    0 | [3, 4, 5] | [0, 3, 4, 5]                    |
+|    1 | [NULL]    | [1, NULL]                       |
+|    2 | NULL      | NULL                            |
+|    3 | []        | [3]                             |
++------+-----------+---------------------------------+
+```
+
+### keywords
+
+ARRAY,PUSHFRONT,ARRAY_PUSHFRONT
\ No newline at end of file
diff --git a/docs/sidebars.json b/docs/sidebars.json
index 252f1040ed..1fdad170ac 100644
--- a/docs/sidebars.json
+++ b/docs/sidebars.json
@@ -294,6 +294,7 @@
                                 
"sql-manual/sql-functions/array-functions/array_enumerate_uniq",
                                 
"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_compact",
                                 
"sql-manual/sql-functions/array-functions/array_concat",
                                 
"sql-manual/sql-functions/array-functions/arrays_overlap",
diff --git 
a/docs/zh-CN/docs/sql-manual/sql-functions/array-functions/array_pushfront.md 
b/docs/zh-CN/docs/sql-manual/sql-functions/array-functions/array_pushfront.md
new file mode 100644
index 0000000000..fa91a3ab7f
--- /dev/null
+++ 
b/docs/zh-CN/docs/sql-manual/sql-functions/array-functions/array_pushfront.md
@@ -0,0 +1,85 @@
+---
+{
+    "title": "array_pushfront",
+    "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_pushfront
+
+<version since="1.2.3">
+
+array_pushfront
+
+</version>
+
+### description
+
+#### Syntax
+
+```sql
+Array<T> array_pushfront(Array<T> arr, T value)
+```
+将value添加到数组的开头.
+
+#### Returned value
+
+返回添加value后的数组
+
+类型: Array.
+
+### notice
+
+`只支持在向量化引擎中使用`
+
+### example
+
+```
+mysql> select array_pushfront([1, 2], 3);
++---------------------------------+
+| array_pushfront(ARRAY(1, 2), 3) |
++---------------------------------+
+| [3, 1, 2]                       |
++---------------------------------+
+
+mysql> select col3, array_pushfront(col3, 6) from array_test;
++-----------+----------------------------+
+| col3      | array_pushfront(`col3`, 6) |
++-----------+----------------------------+
+| [3, 4, 5] | [6, 3, 4, 5]               |
+| [NULL]    | [6, NULL]                  |
+| NULL      | NULL                       |
+| []        | [6]                        |
++-----------+----------------------------+
+
+mysql> select col1, col3, array_pushfront(col3, col1) from array_test;
++------+-----------+---------------------------------+
+| col1 | col3      | array_pushfront(`col3`, `col1`) |
++------+-----------+---------------------------------+
+|    0 | [3, 4, 5] | [0, 3, 4, 5]                    |
+|    1 | [NULL]    | [1, NULL]                       |
+|    2 | NULL      | NULL                            |
+|    3 | []        | [3]                             |
++------+-----------+---------------------------------+
+```
+
+### keywords
+
+ARRAY,PUSHFRONT,ARRAY_PUSHFRONT
\ 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 a54594b50a..ef577b06c1 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
@@ -1531,6 +1531,7 @@ public class FunctionCallExpr extends Expr {
                 || fnName.getFunction().equalsIgnoreCase("array_slice")
                 || fnName.getFunction().equalsIgnoreCase("array_popback")
                 || fnName.getFunction().equalsIgnoreCase("array_popfront")
+                || fnName.getFunction().equalsIgnoreCase("array_pushfront")
                 || fnName.getFunction().equalsIgnoreCase("reverse")
                 || fnName.getFunction().equalsIgnoreCase("%element_slice%")
                 || fnName.getFunction().equalsIgnoreCase("array_except")
diff --git a/gensrc/script/doris_builtins_functions.py 
b/gensrc/script/doris_builtins_functions.py
index 33e783ea62..3954d92693 100644
--- a/gensrc/script/doris_builtins_functions.py
+++ b/gensrc/script/doris_builtins_functions.py
@@ -585,6 +585,25 @@ visible_functions = [
     [['array_popfront'], 'ARRAY_VARCHAR', ['ARRAY_VARCHAR'], ''],
     [['array_popfront'], 'ARRAY_STRING', ['ARRAY_STRING'], ''],
 
+    [['array_pushfront'], 'ARRAY_BOOLEAN',    ['ARRAY_BOOLEAN', 'BOOLEAN'], 
'ALWAYS_NULLABLE'],
+    [['array_pushfront'], 'ARRAY_TINYINT',    ['ARRAY_TINYINT', 'TINYINT'], 
'ALWAYS_NULLABLE'],
+    [['array_pushfront'], 'ARRAY_SMALLINT',   ['ARRAY_SMALLINT', 'SMALLINT'], 
'ALWAYS_NULLABLE'],
+    [['array_pushfront'], 'ARRAY_INT',        ['ARRAY_INT', 'INT'], 
'ALWAYS_NULLABLE'],
+    [['array_pushfront'], 'ARRAY_BIGINT',     ['ARRAY_BIGINT', 'BIGINT'], 
'ALWAYS_NULLABLE'],
+    [['array_pushfront'], 'ARRAY_LARGEINT',   ['ARRAY_LARGEINT', 'LARGEINT'], 
'ALWAYS_NULLABLE'],
+    [['array_pushfront'], 'ARRAY_DATETIME',   ['ARRAY_DATETIME', 'DATETIME'], 
'ALWAYS_NULLABLE'],
+    [['array_pushfront'], 'ARRAY_DATE',       ['ARRAY_DATE', 'DATE'], 
'ALWAYS_NULLABLE'],
+    [['array_pushfront'], 'ARRAY_DATETIMEV2', ['ARRAY_DATETIMEV2', 
'DATETIMEV2'], 'ALWAYS_NULLABLE'],
+    [['array_pushfront'], 'ARRAY_DATEV2',     ['ARRAY_DATEV2', 'DATEV2'], 
'ALWAYS_NULLABLE'],
+    [['array_pushfront'], 'ARRAY_FLOAT',      ['ARRAY_FLOAT', 'FLOAT'], 
'ALWAYS_NULLABLE'],
+    [['array_pushfront'], 'ARRAY_DOUBLE',     ['ARRAY_DOUBLE', 'DOUBLE'], 
'ALWAYS_NULLABLE'],
+    [['array_pushfront'], 'ARRAY_DECIMALV2',  ['ARRAY_DECIMALV2', 
'DECIMALV2'], 'ALWAYS_NULLABLE'],
+    [['array_pushfront'], 'ARRAY_DECIMAL32',  ['ARRAY_DECIMAL32', 
'DECIMAL32'], 'ALWAYS_NULLABLE'],
+    [['array_pushfront'], 'ARRAY_DECIMAL64',  ['ARRAY_DECIMAL64', 
'DECIMAL64'], 'ALWAYS_NULLABLE'],
+    [['array_pushfront'], 'ARRAY_DECIMAL128', ['ARRAY_DECIMAL128', 
'DECIMAL128'], 'ALWAYS_NULLABLE'],
+    [['array_pushfront'], 'ARRAY_VARCHAR',    ['ARRAY_VARCHAR', 'VARCHAR'], 
'ALWAYS_NULLABLE'],
+    [['array_pushfront'], '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 b37edf7d80..d85cf5ff5e 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
@@ -1171,6 +1171,127 @@
 8      [2015-03-13 12:36:38]
 9      [2015-03-13 12:36:38]
 
+-- !select --
+1      [1, 1, 2, 3]
+2      [2, 4]
+3      [3]
+4      [4, 1, 2, 3, 4, 5, 4, 3, 2, 1]
+5      [5]
+6      [6, 1, 2, 3, 4, 5, 4, 3, 2, 1]
+7      [7, 8, 9, NULL, 10, NULL]
+8      [8, 1, 2, 3, 3, 4, 4, NULL]
+9      [9, 1, 2, 3]
+
+-- !select --
+1      [1, 1, 2, 3]
+2      [1, 4]
+3      [1]
+4      [1, 1, 2, 3, 4, 5, 4, 3, 2, 1]
+5      [1]
+6      [1, 1, 2, 3, 4, 5, 4, 3, 2, 1]
+7      [1, 8, 9, NULL, 10, NULL]
+8      [1, 1, 2, 3, 3, 4, 4, NULL]
+9      [1, 1, 2, 3]
+
+-- !select --
+1      ['a', 'a', 'b', '']
+2      \N
+3      ['a']
+4      ['a']
+5      ['a', 'a', 'b', 'c', 'd', 'c', 'b', 'a']
+6      ['a', 'a', 'b', 'c', 'd', 'c', 'b', 'a']
+7      ['a', 'f', NULL, 'g', NULL, 'h']
+8      ['a', 'a', 'b', 'b', 'b']
+9      ['a', 'a', 'b', '']
+
+-- !select --
+1      [NULL, 'a', 'b', '']
+2      \N
+3      [NULL]
+4      [NULL]
+5      [NULL, 'a', 'b', 'c', 'd', 'c', 'b', 'a']
+6      [NULL, 'a', 'b', 'c', 'd', 'c', 'b', 'a']
+7      [NULL, 'f', NULL, 'g', NULL, 'h']
+8      [NULL, 'a', 'b', 'b', 'b']
+9      [NULL, 'a', 'b', '']
+
+-- !select --
+1      [NULL, 1, 2]
+2      [NULL, 5]
+3      \N
+4      [NULL]
+5      \N
+6      \N
+7      \N
+8      [NULL, 1, 2, 2, 3]
+9      [NULL, 1, 2]
+
+-- !select --
+1      ['hi', 'hi']
+2      ['hi', 'hi2']
+3      ['hi', 'hi3']
+4      \N
+5      \N
+6      \N
+7      \N
+8      ['hi', 'hi', 'hi', 'hello']
+9      ['hi', 'hi']
+
+-- !select --
+1      ['hi222', 'hi']
+2      ['hi222', 'hi2']
+3      ['hi222', 'hi3']
+4      \N
+5      \N
+6      \N
+7      \N
+8      ['hi222', 'hi', 'hi', 'hello']
+9      ['hi222', 'hi']
+
+-- !select --
+1      [NULL, 2015-03-13]
+2      \N
+3      \N
+4      \N
+5      \N
+6      \N
+7      \N
+8      [NULL, 2015-03-13]
+9      [NULL, 2015-03-13, 2015-03-13, 2015-03-14]
+
+-- !select --
+1      [2023-03-05, 2023-02-05, 2023-02-06]
+2      [2023-03-05, 2023-01-05, 2023-01-06]
+3      \N
+4      \N
+5      \N
+6      \N
+7      \N
+8      \N
+9      \N
+
+-- !select --
+1      [2023-03-08 10:30:00.999, 2022-10-15 10:30:00.999, 2022-08-31 
12:00:00.999]
+2      [2023-03-08 10:30:00.999, 2022-11-15 10:30:00.999, 2022-01-31 
12:00:00.999]
+3      \N
+4      \N
+5      \N
+6      \N
+7      \N
+8      \N
+9      \N
+
+-- !select --
+1      [NULL, 2022-10-15 10:30:00.999, 2022-08-31 12:00:00.999]
+2      [NULL, 2022-11-15 10:30:00.999, 2022-01-31 12:00:00.999]
+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 145a9f5f16..006a648a6b 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
@@ -725,3 +725,27 @@ _
 -- !sql --
 [1, 1, 2]
 
+-- !sql --
+[6, 1, 2, 3]
+
+-- !sql --
+[NULL, 1, 2, 3]
+
+-- !sql --
+\N
+
+-- !sql --
+[9.999, 1.111, 2.222, 3.333]
+
+-- !sql --
+['dddd', 'aaa', 'bbb', 'ccc']
+
+-- !sql --
+[999.28, 12.99, 34.99]
+
+-- !sql --
+[2023-02-05, 2023-03-05, 2023-03-04]
+
+-- !sql --
+[2023-03-08 16:23:54.999, 2023-03-05 12:23:24.999, 2023-03-05 15:23:23.997]
+
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 cc5cb7dac8..752aeec223 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
@@ -118,3 +118,23 @@
 [22.678, 33.6789, 22.678, 33.6789, 22.678, 33.6789]
 [23.678, 34.6789, 23.678, 34.6789, 23.678, 34.6789]
 
+-- !select --
+[2022-12-02 22:23:23.997, 2022-12-02 22:23:24.999]
+[2022-12-02 22:23:23.997, 2022-12-02 22:23:24.999]
+
+-- !select --
+[2023-03-08 23:23:23.997, 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]
+
+-- !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 22:23:24.999, 
2022-12-01 23: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 22:23:24.999, 
2022-12-02 23:23:24.999]
+
+-- !select --
+[25.99, 22.678, 33.6789]
+[25.99, 23.678, 34.6789]
+
+-- !select --
+22.678 [22.678, 33.6789]       [22.678, 22.678, 33.6789]
+23.678 [23.678, 34.6789]       [23.678, 23.678, 34.6789]
+
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 5c08acdbec..12f5628e02 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
@@ -187,6 +187,18 @@ suite("test_array_functions") {
     qt_select "SELECT k1, array_compact(k6) from ${tableName} ORDER BY k1"
     qt_select "SELECT k1, array_compact(k7) from ${tableName} ORDER BY k1"
 
+    qt_select "SELECT k1, array_pushfront(k2, k1) FROM ${tableName} ORDER BY 
k1"
+    qt_select "SELECT k1, array_pushfront(k2, 1) FROM ${tableName} ORDER BY k1"
+    qt_select "SELECT k1, array_pushfront(k3, 'a') FROM ${tableName} ORDER BY 
k1"
+    qt_select "SELECT k1, array_pushfront(k3, null) FROM ${tableName} ORDER BY 
k1"
+    qt_select "SELECT k1, array_pushfront(k4, null) FROM ${tableName} ORDER BY 
k1"
+    qt_select "SELECT k1, array_pushfront(k5, 'hi') FROM ${tableName} ORDER BY 
k1"
+    qt_select "SELECT k1, array_pushfront(k5, 'hi222') FROM ${tableName} ORDER 
BY k1"
+    qt_select "SELECT k1, array_pushfront(k6, null) from ${tableName} ORDER BY 
k1"
+    qt_select "SELECT k1, array_pushfront(k8, cast('2023-03-05' as datev2)) 
FROM ${tableName} ORDER BY k1"
+    qt_select "SELECT k1, array_pushfront(k10, cast('2023-03-08 10:30:00.999' 
as datetimev2(3))) FROM ${tableName} ORDER BY k1"
+    qt_select "SELECT k1, array_pushfront(k10, 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 5102c2b2cf..906cb8ceb9 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
@@ -291,6 +291,16 @@ suite("test_array_functions_by_literal") {
     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'])"
+    
+    // array_pushfront
+    qt_sql "select array_pushfront([1, 2, 3], 6)"
+    qt_sql "select array_pushfront([1, 2, 3], null)"
+    qt_sql "select array_pushfront(null, 6)"
+    qt_sql "select array_pushfront([1.111, 2.222, 3.333], 9.999)"
+    qt_sql "select array_pushfront(['aaa', 'bbb', 'ccc'], 'dddd')"
+    qt_sql "select array_pushfront(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_pushfront(array(cast ('2023-03-05' as datev2), cast 
('2023-03-04' as datev2)), cast ('2023-02-05' as datev2))"
+    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)))"
 
     // abnormal test
     try {
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 db85a98b64..93b93d2d58 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
@@ -80,5 +80,11 @@ suite("test_array_with_scale_type") {
         qt_select """select array_concat(c_array_datetimev2, 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_concat(c_array_decimal, c_array_decimal, 
c_array_decimal) from ${tableName}"""
 
+        qt_select "select array_pushfront(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_pushfront(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_pushfront(c_array_datetimev2, c_datetimev2) from ${tableName}"
+        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}"
+
         sql "DROP TABLE IF EXISTS ${tableName}"
 }
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to