You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2023/04/08 07:50:36 UTC

[doris] branch master updated: [vectorized](function) support array_repeat function to be compatible with hive syntax (#18028)

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 0517616242 [vectorized](function) support array_repeat function to be compatible with hive syntax (#18028)
0517616242 is described below

commit 05176162429dfc50b533ce44f1c9457a7effe18c
Author: ZhangYu0123 <67...@users.noreply.github.com>
AuthorDate: Sat Apr 8 15:50:28 2023 +0800

    [vectorized](function) support array_repeat function to be compatible with hive syntax (#18028)
    
    
    ---------
    
    Co-authored-by: zhangyu209 <zh...@meituan.com>
---
 .../array/function_array_with_constant.cpp         | 34 +++++++--
 .../array-functions/array_with_constant.md         | 42 +++++------
 .../array-functions/array_with_constant.md         | 42 ++++++-----
 gensrc/script/doris_builtins_functions.py          | 19 +++++
 .../array_functions/test_array_functions.out       | 86 +++++++++++-----------
 .../test_array_functions_by_literal.out            | 16 ++--
 .../test_array_functions_with_where.out            |  4 +-
 .../array_functions/test_array_functions.groovy    |  8 +-
 .../test_array_functions_by_literal.groovy         |  8 +-
 .../test_array_functions_with_where.groovy         |  2 +-
 10 files changed, 152 insertions(+), 109 deletions(-)

diff --git a/be/src/vec/functions/array/function_array_with_constant.cpp b/be/src/vec/functions/array/function_array_with_constant.cpp
index af2600cbaf..6c4466be55 100644
--- a/be/src/vec/functions/array/function_array_with_constant.cpp
+++ b/be/src/vec/functions/array/function_array_with_constant.cpp
@@ -25,12 +25,14 @@
 
 namespace doris::vectorized {
 
-/* array_with_constant(num, T) - return array of constants with length num.
+/* array_with_constant(num, T) / array_repeat(T, num)  - return array of constants with length num.
  * array_with_constant(2, 'xxx') = ['xxx', 'xxx']
+ * array_repeat('xxx', 2) = ['xxx', 'xxx']
  */
+template <typename FunctionType>
 class FunctionArrayWithConstant : public IFunction {
 public:
-    static constexpr auto name = "array_with_constant";
+    static constexpr auto name = FunctionType::name;
     static FunctionPtr create() { return std::make_shared<FunctionArrayWithConstant>(); }
 
     /// Get function name.
@@ -44,13 +46,16 @@ public:
     bool use_default_implementation_for_nulls() const override { return false; }
 
     DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
-        return std::make_shared<DataTypeArray>(make_nullable(arguments[1]));
+        return std::make_shared<DataTypeArray>(
+                make_nullable(arguments[FunctionType::param_val_idx]));
     }
 
     Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
                         size_t result, size_t input_rows_count) override {
-        auto num = block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
-        auto value = block.get_by_position(arguments[1]).column->convert_to_full_column_if_const();
+        auto num = block.get_by_position(arguments[FunctionType::param_num_idx])
+                           .column->convert_to_full_column_if_const();
+        auto value = block.get_by_position(arguments[FunctionType::param_val_idx])
+                             .column->convert_to_full_column_if_const();
         auto offsets_col = ColumnVector<ColumnArray::Offset64>::create();
         ColumnArray::Offsets64& offsets = offsets_col->get_data();
         offsets.reserve(input_rows_count);
@@ -79,8 +84,25 @@ public:
     }
 };
 
+struct NameArrayWithConstant {
+    static constexpr auto name = "array_with_constant";
+
+    static constexpr auto param_num_idx = 0;
+
+    static constexpr auto param_val_idx = 1;
+};
+
+struct NameArrayRepeat {
+    static constexpr auto name = "array_repeat";
+
+    static constexpr auto param_num_idx = 1;
+
+    static constexpr auto param_val_idx = 0;
+};
+
 void register_function_array_with_constant(SimpleFunctionFactory& factory) {
-    factory.register_function<FunctionArrayWithConstant>();
+    factory.register_function<FunctionArrayWithConstant<NameArrayWithConstant>>();
+    factory.register_function<FunctionArrayWithConstant<NameArrayRepeat>>();
 }
 
 } // namespace doris::vectorized
diff --git a/docs/en/docs/sql-manual/sql-functions/array-functions/array_with_constant.md b/docs/en/docs/sql-manual/sql-functions/array-functions/array_with_constant.md
index db0e6aae41..9b9982c32b 100644
--- a/docs/en/docs/sql-manual/sql-functions/array-functions/array_with_constant.md
+++ b/docs/en/docs/sql-manual/sql-functions/array-functions/array_with_constant.md
@@ -36,9 +36,10 @@ array_with_constant
 
 ```
 ARRAY<T> array_with_constant(n, T)
+ARRAY<T> array_repeat(T, n)
 ```
 
-get array of constants with n length
+get array of constants with n length, array_repeat has the same function as array_with_constant and is used to be compatible with the hive syntax format
 ### notice
 
 `Only supported in vectorized engine`
@@ -48,32 +49,31 @@ get array of constants with n length
 ```
 mysql> set enable_vectorized_engine=true;
 
-mysql> select array_with_constant(2, "hello");
-+---------------------------------+
-| array_with_constant(2, 'hello') |
-+---------------------------------+
-| ['hello', 'hello']              |
-+---------------------------------+
+mysql> select array_with_constant(2, "hello"), array_repeat("hello", 2);
++---------------------------------+--------------------------+
+| array_with_constant(2, 'hello') | array_repeat('hello', 2) |
++---------------------------------+--------------------------+
+| ['hello', 'hello']              | ['hello', 'hello']       |
++---------------------------------+--------------------------+
 1 row in set (0.04 sec)
 
-mysql> select array_with_constant(3, 12345);
-+-------------------------------+
-| array_with_constant(3, 12345) |
-+-------------------------------+
-| [12345, 12345, 12345]         |
-+-------------------------------+
+mysql> select array_with_constant(3, 12345), array_repeat(12345, 3);
++-------------------------------+------------------------+
+| array_with_constant(3, 12345) | array_repeat(12345, 3) | 
++-------------------------------+------------------------+
+| [12345, 12345, 12345]         | [12345, 12345, 12345]  |
++-------------------------------+------------------------+
 1 row in set (0.01 sec)
 
-mysql> select array_with_constant(3, null);
-+------------------------------+
-| array_with_constant(3, NULL) |
-+------------------------------+
-| [NULL, NULL, NULL]           |
-+------------------------------+
+mysql> select array_with_constant(3, null), array_repeat(null, 3);
++------------------------------+-----------------------+
+| array_with_constant(3, NULL) | array_repeat(NULL, 3) |
++------------------------------+-----------------------+
+| [NULL, NULL, NULL]           |  [NULL, NULL, NULL]   |
++------------------------------+-----------------------+
 1 row in set (0.01 sec)
-
 ```
 
 ### keywords
 
-ARRAY,WITH_CONSTANT,ARRAY_WITH_CONSTANT
+ARRAY,WITH_CONSTANT,ARRAY_WITH_CONSTANT,ARRAY_REPEAT
diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/array-functions/array_with_constant.md b/docs/zh-CN/docs/sql-manual/sql-functions/array-functions/array_with_constant.md
index 96ae49b908..99e73da2b0 100644
--- a/docs/zh-CN/docs/sql-manual/sql-functions/array-functions/array_with_constant.md
+++ b/docs/zh-CN/docs/sql-manual/sql-functions/array-functions/array_with_constant.md
@@ -27,6 +27,7 @@ under the License.
 <version since="1.2.0">
 
 array_with_constant
+array_repeat
 
 </version>
 
@@ -36,8 +37,9 @@ array_with_constant
 
 ```
 ARRAY<T> array_with_constant(n, T)
+ARRAY<T> array_repeat(T, n)
 ```
-返回一个数组, 包含n个重复的T常量
+返回一个数组, 包含n个重复的T常量。array_repeat与array_with_constant功能相同,用来兼容hive语法格式。
 
 ### notice
 
@@ -48,31 +50,31 @@ ARRAY<T> array_with_constant(n, T)
 ```
 mysql> set enable_vectorized_engine=true;
 
-mysql> select array_with_constant(2, "hello");
-+---------------------------------+
-| array_with_constant(2, 'hello') |
-+---------------------------------+
-| ['hello', 'hello']              |
-+---------------------------------+
+mysql> select array_with_constant(2, "hello"), array_repeat("hello", 2);
++---------------------------------+--------------------------+
+| array_with_constant(2, 'hello') | array_repeat('hello', 2) |
++---------------------------------+--------------------------+
+| ['hello', 'hello']              | ['hello', 'hello']       |
++---------------------------------+--------------------------+
 1 row in set (0.04 sec)
 
-mysql> select array_with_constant(3, 12345);
-+-------------------------------+
-| array_with_constant(3, 12345) |
-+-------------------------------+
-| [12345, 12345, 12345]         |
-+-------------------------------+
+mysql> select array_with_constant(3, 12345), array_repeat(12345, 3);
++-------------------------------+------------------------+
+| array_with_constant(3, 12345) | array_repeat(12345, 3) | 
++-------------------------------+------------------------+
+| [12345, 12345, 12345]         | [12345, 12345, 12345]  |
++-------------------------------+------------------------+
 1 row in set (0.01 sec)
 
-mysql> select array_with_constant(3, null);
-+------------------------------+
-| array_with_constant(3, NULL) |
-+------------------------------+
-| [NULL, NULL, NULL]           |
-+------------------------------+
+mysql> select array_with_constant(3, null), array_repeat(null, 3);
++------------------------------+-----------------------+
+| array_with_constant(3, NULL) | array_repeat(NULL, 3) |
++------------------------------+-----------------------+
+| [NULL, NULL, NULL]           |  [NULL, NULL, NULL]   |
++------------------------------+-----------------------+
 1 row in set (0.01 sec)
 ```
 
 ### keywords
 
-ARRAY,WITH_CONSTANT,ARRAY_WITH_CONSTANT
+ARRAY,WITH_CONSTANT,ARRAY_WITH_CONSTANT,ARRAY_REPEAT
diff --git a/gensrc/script/doris_builtins_functions.py b/gensrc/script/doris_builtins_functions.py
index 9d357ac8b2..3d175d0fa3 100644
--- a/gensrc/script/doris_builtins_functions.py
+++ b/gensrc/script/doris_builtins_functions.py
@@ -752,6 +752,25 @@ visible_functions = [
     [['array_with_constant'], 'ARRAY_DECIMAL128', ['BIGINT', 'DECIMAL128'], 'ALWAYS_NOT_NULLABLE'],
     [['array_with_constant'], 'ARRAY_VARCHAR', ['BIGINT', 'VARCHAR'], 'ALWAYS_NOT_NULLABLE'],
     [['array_with_constant'], 'ARRAY_STRING', ['BIGINT', 'STRING'], 'ALWAYS_NOT_NULLABLE'],
+
+    [['array_repeat'], 'ARRAY_BOOLEAN', ['BOOLEAN', 'BIGINT'], 'ALWAYS_NOT_NULLABLE'],
+    [['array_repeat'], 'ARRAY_TINYINT', ['TINYINT', 'BIGINT'], 'ALWAYS_NOT_NULLABLE'],
+    [['array_repeat'], 'ARRAY_SMALLINT', ['SMALLINT', 'BIGINT'], 'ALWAYS_NOT_NULLABLE'],
+    [['array_repeat'], 'ARRAY_INT', ['INT', 'BIGINT'], 'ALWAYS_NOT_NULLABLE'],
+    [['array_repeat'], 'ARRAY_BIGINT', ['BIGINT', 'BIGINT'], 'ALWAYS_NOT_NULLABLE'],
+    [['array_repeat'], 'ARRAY_LARGEINT', ['LARGEINT', 'BIGINT'], 'ALWAYS_NOT_NULLABLE'],
+    [['array_repeat'], 'ARRAY_DATETIME', ['DATETIME', 'BIGINT'], 'ALWAYS_NOT_NULLABLE'],
+    [['array_repeat'], 'ARRAY_DATE', ['DATE', 'BIGINT'], 'ALWAYS_NOT_NULLABLE'],
+    [['array_repeat'], 'ARRAY_DATETIMEV2', ['DATETIMEV2', 'BIGINT'], 'ALWAYS_NOT_NULLABLE'],
+    [['array_repeat'], 'ARRAY_DATEV2', ['DATEV2', 'BIGINT'], 'ALWAYS_NOT_NULLABLE'],
+    [['array_repeat'], 'ARRAY_FLOAT', ['FLOAT', 'BIGINT'], 'ALWAYS_NOT_NULLABLE'],
+    [['array_repeat'], 'ARRAY_DOUBLE', ['DOUBLE', 'BIGINT'], 'ALWAYS_NOT_NULLABLE'],
+    [['array_repeat'], 'ARRAY_DECIMALV2', ['DECIMALV2', 'BIGINT'], 'ALWAYS_NOT_NULLABLE'],
+    [['array_repeat'], 'ARRAY_DECIMAL32', ['DECIMAL32', 'BIGINT'], 'ALWAYS_NOT_NULLABLE'],
+    [['array_repeat'], 'ARRAY_DECIMAL64', ['DECIMAL64', 'BIGINT'], 'ALWAYS_NOT_NULLABLE'],
+    [['array_repeat'], 'ARRAY_DECIMAL128', ['DECIMAL128', 'BIGINT'], 'ALWAYS_NOT_NULLABLE'],
+    [['array_repeat'], 'ARRAY_VARCHAR', ['VARCHAR', 'BIGINT'], 'ALWAYS_NOT_NULLABLE'],
+    [['array_repeat'], 'ARRAY_STRING', ['STRING', 'BIGINT'], 'ALWAYS_NOT_NULLABLE'],
     
     [['array_range'], 'ARRAY_INT', ['INT'], 'ALWAYS_NULLABLE'],
     [['array_range'], 'ARRAY_INT', ['INT', 'INT'], 'ALWAYS_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 6f1af6a645..ee258b88e9 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
@@ -912,49 +912,49 @@
 8	\N
 9	\N
 
--- !select --
-1	[1, 1, 1]
-2	[2, 2, 2]
-3	[3, 3, 3]
-4	[4, 4, 4]
-5	[5, 5, 5]
-6	[6, 6, 6]
-7	[7, 7, 7]
-8	[8, 8, 8]
-9	[9, 9, 9]
-
--- !select --
-1	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
-2	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
-3	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
-4	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
-5	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
-6	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
-7	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
-8	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
-9	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
-
--- !select --
-1	['a', 'a']
-2	['a', 'a']
-3	['a', 'a']
-4	['a', 'a']
-5	['a', 'a']
-6	['a', 'a']
-7	['a', 'a']
-8	['a', 'a']
-9	['a', 'a']
-
--- !select --
-1	[123, 123]
-2	[123, 123]
-3	[123, 123]
-4	[123, 123]
-5	[123, 123]
-6	[123, 123]
-7	[123, 123]
-8	[123, 123]
-9	[123, 123]
+-- !select_array_with_constant1 --
+1	[1, 1, 1]	[1, 1, 1]
+2	[2, 2, 2]	[2, 2, 2]
+3	[3, 3, 3]	[3, 3, 3]
+4	[4, 4, 4]	[4, 4, 4]
+5	[5, 5, 5]	[5, 5, 5]
+6	[6, 6, 6]	[6, 6, 6]
+7	[7, 7, 7]	[7, 7, 7]
+8	[8, 8, 8]	[8, 8, 8]
+9	[9, 9, 9]	[9, 9, 9]
+
+-- !select_array_with_constant2 --
+1	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
+2	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
+3	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
+4	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
+5	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
+6	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
+7	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
+8	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
+9	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
+
+-- !select_array_with_constant3 --
+1	['a', 'a']	['a', 'a']
+2	['a', 'a']	['a', 'a']
+3	['a', 'a']	['a', 'a']
+4	['a', 'a']	['a', 'a']
+5	['a', 'a']	['a', 'a']
+6	['a', 'a']	['a', 'a']
+7	['a', 'a']	['a', 'a']
+8	['a', 'a']	['a', 'a']
+9	['a', 'a']	['a', 'a']
+
+-- !select_array_with_constant4 --
+1	[123, 123]	[123, 123]
+2	[123, 123]	[123, 123]
+3	[123, 123]	[123, 123]
+4	[123, 123]	[123, 123]
+5	[123, 123]	[123, 123]
+6	[123, 123]	[123, 123]
+7	[123, 123]	[123, 123]
+8	[123, 123]	[123, 123]
+9	[123, 123]	[123, 123]
 
 -- !select --
 1	[2, 1]
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 bab044992c..0a6df2301f 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
@@ -605,17 +605,17 @@ any_any_1_2___any
 -- !sql --
 _
 
--- !sql --
-['_', '_', '_']
+-- !sql_array_with_constant1 --
+['_', '_', '_']	['_', '_', '_']
 
--- !sql --
-['1', '1']
+-- !sql_array_with_constant2 --
+['1', '1']	['1', '1']
 
--- !sql --
-[1223, 1223, 1223, 1223]
+-- !sql_array_with_constant3 --
+[1223, 1223, 1223, 1223]	[1223, 1223, 1223, 1223]
 
--- !sql --
-[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
+-- !sql_array_with_constant4 --
+[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]	[NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
 
 -- !sql --
 [1, 2, 3, NULL, 4]
diff --git a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_with_where.out b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_with_where.out
index 7950b59cc0..d34ea082a6 100644
--- a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_with_where.out
+++ b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_with_where.out
@@ -15,8 +15,8 @@
 1	3
 2	1
 
--- !select --
-\N	[NULL, NULL, NULL, NULL, NULL]
+-- !select_array_with_constant --
+\N	[NULL, NULL, NULL, NULL, NULL]	[NULL, NULL, NULL, NULL, NULL]
 
 -- !select --
 1	[5, 1]
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 d64ac9b8d3..881704ecd4 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
@@ -135,10 +135,10 @@ suite("test_array_functions") {
     qt_select "SELECT k1, array_popfront(k8) from ${tableName} ORDER BY k1"
     qt_select "SELECT k1, array_popfront(k10) from ${tableName} ORDER BY k1"
     qt_select "SELECT k1, array_popfront(k12) from ${tableName} ORDER BY k1"
-    qt_select "SELECT k1, array_with_constant(3, k1) from ${tableName} ORDER BY k1"
-    qt_select "SELECT k1, array_with_constant(10, null) from ${tableName} ORDER BY k1"
-    qt_select "SELECT k1, array_with_constant(2, 'a') from ${tableName} ORDER BY k1"
-    qt_select "SELECT k1, array_with_constant(2, 123) from ${tableName} ORDER BY k1"
+    qt_select_array_with_constant1 "SELECT k1, array_with_constant(3, k1),  array_repeat(k1, 3) from ${tableName} ORDER BY k1"
+    qt_select_array_with_constant2 "SELECT k1, array_with_constant(10, null), array_repeat(null, 10) from ${tableName} ORDER BY k1"
+    qt_select_array_with_constant3 "SELECT k1, array_with_constant(2, 'a'), array_repeat('a', 2) from ${tableName} ORDER BY k1"
+    qt_select_array_with_constant4 "SELECT k1, array_with_constant(2, 123), array_repeat(123, 2) from ${tableName} ORDER BY k1"
     qt_select "SELECT k1, array(2, k1) from ${tableName} ORDER BY k1"
     qt_select "SELECT k1, array(k1, null, '2020-01-01') from ${tableName} ORDER BY k1"
     qt_select "SELECT k1, array(null, k1) from ${tableName} ORDER BY k1"
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 cbc3852ab1..1e9c1507ab 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
@@ -246,10 +246,10 @@ suite("test_array_functions_by_literal") {
     qt_sql "select array_join([null, null, 1, 2, '', '', null], '_', 'any')"
     qt_sql "select array_join([''], '_')"
     qt_sql "select array_join(['', ''], '_')"
-    qt_sql "select array_with_constant(3, '_')"
-    qt_sql "select array_with_constant(2, '1')"
-    qt_sql "select array_with_constant(4, 1223)"
-    qt_sql "select array_with_constant(8, null)"
+    qt_sql_array_with_constant1 "select array_with_constant(3, '_'), array_repeat('_', 3)"
+    qt_sql_array_with_constant2 "select array_with_constant(2, '1'), array_repeat('1', 2)"
+    qt_sql_array_with_constant3 "select array_with_constant(4, 1223), array_repeat(1223, 4)"
+    qt_sql_array_with_constant4 "select array_with_constant(8, null), array_repeat(null, 8)"
     // array_compact function
     qt_sql "select array_compact([1, 2, 3, 3, null, null, 4, 4])"
     qt_sql "select array_compact([null, null, null])"
diff --git a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_with_where.groovy b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_with_where.groovy
index 6ee5ae1b54..91772b94bb 100644
--- a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_with_where.groovy
+++ b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_with_where.groovy
@@ -43,7 +43,7 @@ suite("test_array_functions_with_where") {
     qt_select "SELECT k1, size(k2) FROM ${tableName} WHERE element_at(k2, 1)=1 ORDER BY k1"
     qt_select "SELECT k1, size(k2) FROM ${tableName} WHERE arrays_overlap(k2, k4) ORDER BY k1"
     qt_select "SELECT k1, size(k2) FROM ${tableName} WHERE cardinality(k2)>0 ORDER BY k1, size(k2)"
-    qt_select "SELECT k1, array_with_constant(5, k1) FROM ${tableName} WHERE k1 is null ORDER BY k1, size(k2)"
+    qt_select_array_with_constant "SELECT k1, array_with_constant(5, k1), array_repeat(k1, 5) FROM ${tableName} WHERE k1 is null ORDER BY k1, size(k2)"
     qt_select "SELECT k1, array(5, k1) FROM ${tableName} WHERE k1 is not null ORDER BY k1, size(k2)"
     qt_select "SELECT k1, array(k1, 'abc') FROM ${tableName} WHERE k1 is not null ORDER BY k1, size(k2)"
     qt_select "SELECT k1, array(null, k1) FROM ${tableName} WHERE k1 is not null ORDER BY k1, size(k2)"


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