This is an automated email from the ASF dual-hosted git repository.
gabriellee 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 0f0fdc75cf7 [Enhancement](test) Add function test templates (#40462)
0f0fdc75cf7 is described below
commit 0f0fdc75cf711fa75aa7afd3695d3b33080083dd
Author: zclllhhjj <[email protected]>
AuthorDate: Sat Sep 14 21:12:22 2024 +0800
[Enhancement](test) Add function test templates (#40462)
---
be/test/vec/function/function_test_template.cpp | 57 +++
.../sql_functions/test_template_one_arg.out | 83 ++++
.../sql_functions/test_template_three_args.out | 471 +++++++++++++++++++++
.../sql_functions/test_template_two_args.out | 279 ++++++++++++
.../sql_functions/test_template_one_arg.groovy | 51 +++
.../sql_functions/test_template_three_args.groovy | 114 +++++
.../sql_functions/test_template_two_args.groovy | 108 +++++
7 files changed, 1163 insertions(+)
diff --git a/be/test/vec/function/function_test_template.cpp
b/be/test/vec/function/function_test_template.cpp
new file mode 100644
index 00000000000..5f2778afc69
--- /dev/null
+++ b/be/test/vec/function/function_test_template.cpp
@@ -0,0 +1,57 @@
+// 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.
+
+#include <string>
+
+#include "function_test_util.h"
+#include "vec/core/types.h"
+#include "vec/data_types/data_type_number.h"
+#include "vec/data_types/data_type_string.h"
+
+namespace doris::vectorized {
+
+TEST(FunctionTestTemplate, two_args_template) {
+ std::string func_name = "atan2";
+
+ BaseInputTypeSet input_types = {TypeIndex::Float64, TypeIndex::Float64};
+
+ DataSet data_set = {
+ {{-1.0, -2.0}, -2.677945044588987}, {{0.0, 0.0}, 0.0},
+ {{0.5, 0.5}, 0.7853981633974483}, {{M_PI, M_PI / 2},
1.1071487177940904},
+ {{1e100, 1e-100}, 1.5707963267948966}, {{Null(), Null()}, Null()}};
+
+ static_cast<void>(
+ check_function_all_arg_comb<DataTypeFloat64, true>(func_name,
input_types, data_set));
+}
+
+TEST(FunctionTestTemplate, three_args_template) {
+ std::string func_name = "concat";
+
+ BaseInputTypeSet input_types = {TypeIndex::String, TypeIndex::String,
TypeIndex::String};
+
+ DataSet data_set = {{{std::string(""), std::string(""), std::string("")},
std::string("")},
+ {{std::string("123"), std::string("456"),
std::string("789")},
+ std::string("123456789")},
+ {{std::string("123"), Null(), std::string("789")},
Null()},
+ {{std::string("中文"), std::string("中文"),
std::string("中文")},
+ std::string("中文中文中文")},
+ {{std::string(" "), std::string(" "),
std::string(" ")},
+ std::string(" ")}};
+
+ check_function_all_arg_comb<DataTypeString, true>(func_name, input_types,
data_set);
+}
+} // namespace doris::vectorized
\ No newline at end of file
diff --git
a/regression-test/data/query_p0/sql_functions/test_template_one_arg.out
b/regression-test/data/query_p0/sql_functions/test_template_one_arg.out
new file mode 100644
index 00000000000..1648b8ad2b0
--- /dev/null
+++ b/regression-test/data/query_p0/sql_functions/test_template_one_arg.out
@@ -0,0 +1,83 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !empty_nullable --
+
+-- !empty_not_nullable --
+
+-- !all_null --
+\N
+\N
+\N
+
+-- !nullable --
+\N
+\N
+\N
+\N
+-0.1001674211615598
+-1.5707963267948966
+0.0
+0.0
+0.1001674211615598
+1.0E-100
+1.0E-15
+1.5707963267948966
+
+-- !not_nullable --
+\N
+\N
+\N
+-0.1001674211615598
+-1.5707963267948966
+0.0
+0.0
+0.0
+0.1001674211615598
+1.0E-100
+1.0E-15
+1.5707963267948966
+
+-- !nullable_no_null --
+\N
+\N
+\N
+-0.1001674211615598
+-1.5707963267948966
+0.0
+0.0
+0.0
+0.1001674211615598
+1.0E-100
+1.0E-15
+1.5707963267948966
+
+-- !const_nullable --
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+
+-- !const_not_nullable --
+0.5235987755982989
+0.5235987755982989
+0.5235987755982989
+0.5235987755982989
+0.5235987755982989
+0.5235987755982989
+0.5235987755982989
+0.5235987755982989
+0.5235987755982989
+0.5235987755982989
+0.5235987755982989
+0.5235987755982989
+
+-- !const_nullable_no_null --
+0.5235987755982989
+
diff --git
a/regression-test/data/query_p0/sql_functions/test_template_three_args.out
b/regression-test/data/query_p0/sql_functions/test_template_three_args.out
new file mode 100644
index 00000000000..b85ce8c74e1
--- /dev/null
+++ b/regression-test/data/query_p0/sql_functions/test_template_three_args.out
@@ -0,0 +1,471 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !empty_nullable --
+
+-- !empty_not_nullable --
+
+-- !empty_partial_nullable --
+
+-- !all_null --
+\N
+\N
+\N
+
+-- !nullable --
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+
+
+
+
+
+
+
+
+ !@#@#$#^$%%$^
+ 123123
+ \\a\\b\\c\\d
+ 中文
+ !@#@#$#^$%%$^
+ !@#@#$#^$%%$^
+ !@#@#$#^$%%$^
+ !@#@#$#^$%%$^
+ !@#@#$#^$%%$^!@#@#$#^$%%$^
+ !@#@#$#^$%%$^123123
+ !@#@#$#^$%%$^\\a\\b\\c\\d
+ !@#@#$#^$%%$^中文
+ 123123
+ 123123
+ 123123
+ 123123
+ 123123!@#@#$#^$%%$^
+ 123123123123
+ 123123\\a\\b\\c\\d
+ 123123中文
+ \\a\\b\\c\\d
+ \\a\\b\\c\\d
+ \\a\\b\\c\\d
+ \\a\\b\\c\\d
+ \\a\\b\\c\\d!@#@#$#^$%%$^
+ \\a\\b\\c\\d123123
+ \\a\\b\\c\\d\\a\\b\\c\\d
+ \\a\\b\\c\\d中文
+ 中文
+ 中文
+ 中文
+ 中文
+ 中文!@#@#$#^$%%$^
+ 中文123123
+ 中文\\a\\b\\c\\d
+ 中文中文
+!@#@#$#^$%%$^
+!@#@#$#^$%%$^
+!@#@#$#^$%%$^
+!@#@#$#^$%%$^
+!@#@#$#^$%%$^
+!@#@#$#^$%%$^
+!@#@#$#^$%%$^
+!@#@#$#^$%%$^ !@#@#$#^$%%$^
+!@#@#$#^$%%$^ 123123
+!@#@#$#^$%%$^ \\a\\b\\c\\d
+!@#@#$#^$%%$^ 中文
+!@#@#$#^$%%$^!@#@#$#^$%%$^
+!@#@#$#^$%%$^!@#@#$#^$%%$^
+!@#@#$#^$%%$^!@#@#$#^$%%$^
+!@#@#$#^$%%$^!@#@#$#^$%%$^
+!@#@#$#^$%%$^!@#@#$#^$%%$^!@#@#$#^$%%$^
+!@#@#$#^$%%$^!@#@#$#^$%%$^123123
+!@#@#$#^$%%$^!@#@#$#^$%%$^\\a\\b\\c\\d
+!@#@#$#^$%%$^!@#@#$#^$%%$^中文
+!@#@#$#^$%%$^123123
+!@#@#$#^$%%$^123123
+!@#@#$#^$%%$^123123
+!@#@#$#^$%%$^123123
+!@#@#$#^$%%$^123123!@#@#$#^$%%$^
+!@#@#$#^$%%$^123123123123
+!@#@#$#^$%%$^123123\\a\\b\\c\\d
+!@#@#$#^$%%$^123123中文
+!@#@#$#^$%%$^\\a\\b\\c\\d
+!@#@#$#^$%%$^\\a\\b\\c\\d
+!@#@#$#^$%%$^\\a\\b\\c\\d
+!@#@#$#^$%%$^\\a\\b\\c\\d
+!@#@#$#^$%%$^\\a\\b\\c\\d!@#@#$#^$%%$^
+!@#@#$#^$%%$^\\a\\b\\c\\d123123
+!@#@#$#^$%%$^\\a\\b\\c\\d\\a\\b\\c\\d
+!@#@#$#^$%%$^\\a\\b\\c\\d中文
+!@#@#$#^$%%$^中文
+!@#@#$#^$%%$^中文
+!@#@#$#^$%%$^中文
+!@#@#$#^$%%$^中文
+!@#@#$#^$%%$^中文!@#@#$#^$%%$^
+!@#@#$#^$%%$^中文123123
+!@#@#$#^$%%$^中文\\a\\b\\c\\d
+!@#@#$#^$%%$^中文中文
+123123
+123123
+123123
+123123
+123123
+123123
+123123
+123123 !@#@#$#^$%%$^
+123123 123123
+123123 \\a\\b\\c\\d
+123123 中文
+123123!@#@#$#^$%%$^
+123123!@#@#$#^$%%$^
+123123!@#@#$#^$%%$^
+123123!@#@#$#^$%%$^
+123123!@#@#$#^$%%$^!@#@#$#^$%%$^
+123123!@#@#$#^$%%$^123123
+123123!@#@#$#^$%%$^\\a\\b\\c\\d
+123123!@#@#$#^$%%$^中文
+123123123123
+123123123123
+123123123123
+123123123123
+123123123123!@#@#$#^$%%$^
+123123123123123123
+123123123123\\a\\b\\c\\d
+123123123123中文
+123123\\a\\b\\c\\d
+123123\\a\\b\\c\\d
+123123\\a\\b\\c\\d
+123123\\a\\b\\c\\d
+123123\\a\\b\\c\\d!@#@#$#^$%%$^
+123123\\a\\b\\c\\d123123
+123123\\a\\b\\c\\d\\a\\b\\c\\d
+123123\\a\\b\\c\\d中文
+123123中文
+123123中文
+123123中文
+123123中文
+123123中文!@#@#$#^$%%$^
+123123中文123123
+123123中文\\a\\b\\c\\d
+123123中文中文
+\\a\\b\\c\\d
+\\a\\b\\c\\d
+\\a\\b\\c\\d
+\\a\\b\\c\\d
+\\a\\b\\c\\d
+\\a\\b\\c\\d
+\\a\\b\\c\\d
+\\a\\b\\c\\d !@#@#$#^$%%$^
+\\a\\b\\c\\d 123123
+\\a\\b\\c\\d \\a\\b\\c\\d
+\\a\\b\\c\\d 中文
+\\a\\b\\c\\d!@#@#$#^$%%$^
+\\a\\b\\c\\d!@#@#$#^$%%$^
+\\a\\b\\c\\d!@#@#$#^$%%$^
+\\a\\b\\c\\d!@#@#$#^$%%$^
+\\a\\b\\c\\d!@#@#$#^$%%$^!@#@#$#^$%%$^
+\\a\\b\\c\\d!@#@#$#^$%%$^123123
+\\a\\b\\c\\d!@#@#$#^$%%$^\\a\\b\\c\\d
+\\a\\b\\c\\d!@#@#$#^$%%$^中文
+\\a\\b\\c\\d123123
+\\a\\b\\c\\d123123
+\\a\\b\\c\\d123123
+\\a\\b\\c\\d123123
+\\a\\b\\c\\d123123!@#@#$#^$%%$^
+\\a\\b\\c\\d123123123123
+\\a\\b\\c\\d123123\\a\\b\\c\\d
+\\a\\b\\c\\d123123中文
+\\a\\b\\c\\d\\a\\b\\c\\d
+\\a\\b\\c\\d\\a\\b\\c\\d
+\\a\\b\\c\\d\\a\\b\\c\\d
+\\a\\b\\c\\d\\a\\b\\c\\d
+\\a\\b\\c\\d\\a\\b\\c\\d!@#@#$#^$%%$^
+\\a\\b\\c\\d\\a\\b\\c\\d123123
+\\a\\b\\c\\d\\a\\b\\c\\d\\a\\b\\c\\d
+\\a\\b\\c\\d\\a\\b\\c\\d中文
+\\a\\b\\c\\d中文
+\\a\\b\\c\\d中文
+\\a\\b\\c\\d中文
+\\a\\b\\c\\d中文
+\\a\\b\\c\\d中文!@#@#$#^$%%$^
+\\a\\b\\c\\d中文123123
+\\a\\b\\c\\d中文\\a\\b\\c\\d
+\\a\\b\\c\\d中文中文
+中文
+中文
+中文
+中文
+中文
+中文
+中文
+中文 !@#@#$#^$%%$^
+中文 123123
+中文 \\a\\b\\c\\d
+中文 中文
+中文!@#@#$#^$%%$^
+中文!@#@#$#^$%%$^
+中文!@#@#$#^$%%$^
+中文!@#@#$#^$%%$^
+中文!@#@#$#^$%%$^!@#@#$#^$%%$^
+中文!@#@#$#^$%%$^123123
+中文!@#@#$#^$%%$^\\a\\b\\c\\d
+中文!@#@#$#^$%%$^中文
+中文123123
+中文123123
+中文123123
+中文123123
+中文123123!@#@#$#^$%%$^
+中文123123123123
+中文123123\\a\\b\\c\\d
+中文123123中文
+中文\\a\\b\\c\\d
+中文\\a\\b\\c\\d
+中文\\a\\b\\c\\d
+中文\\a\\b\\c\\d
+中文\\a\\b\\c\\d!@#@#$#^$%%$^
+中文\\a\\b\\c\\d123123
+中文\\a\\b\\c\\d\\a\\b\\c\\d
+中文\\a\\b\\c\\d中文
+中文中文
+中文中文
+中文中文
+中文中文
+中文中文!@#@#$#^$%%$^
+中文中文123123
+中文中文\\a\\b\\c\\d
+中文中文中文
+
+-- !not_nullable --
+
+
+
+!@#@#$#^$%%$^!@#@#$#^$%%$^!@#@#$#^$%%$^
+123123123123123123
+\\a\\b\\c\\d\\a\\b\\c\\d\\a\\b\\c\\d
+中文中文中文
+
+-- !partial_nullable --
+\N
+
+
+!@#@#$#^$%%$^!@#@#$#^$%%$^!@#@#$#^$%%$^
+123123123123123123
+\\a\\b\\c\\d\\a\\b\\c\\d\\a\\b\\c\\d
+中文中文中文
+
+-- !nullable_no_null --
+
+
+
+!@#@#$#^$%%$^!@#@#$#^$%%$^!@#@#$#^$%%$^
+123123123123123123
+\\a\\b\\c\\d\\a\\b\\c\\d\\a\\b\\c\\d
+中文中文中文
+
+-- !const_nullable --
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+
+-- !partial_const_nullable --
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+
+-- !const_not_nullable --
+abc
+abc
+abc
+abc
+abc
+abc
+abc
+
+-- !const_other_nullable --
+\N
+x
+x
+x!@#@#$#^$%%$^!@#@#$#^$%%$^
+x123123123123
+x\\a\\b\\c\\d\\a\\b\\c\\d
+x中文中文
+
+-- !const_other_not_nullable --
+xx
+xx
+xx
+xx!@#@#$#^$%%$^
+xx123123
+xx\\a\\b\\c\\d
+xx中文
+
+-- !const_nullable_no_null --
+abc中文xxx
+
+-- !const_partial_nullable_no_null --
+xyzaa
+
+-- !const1 --
+\N
+xyz
+xyz
+xyz!@#@#$#^$%%$^!@#@#$#^$%%$^
+xyz123123123123
+xyz\\a\\b\\c\\d\\a\\b\\c\\d
+xyz中文中文
+
+-- !const12 --
+\N
+xyzabc
+xyzabc
+xyzabc!@#@#$#^$%%$^
+xyzabc123123
+xyzabc\\a\\b\\c\\d
+xyzabc中文
+
+-- !const23 --
+ xyzabc
+!@#@#$#^$%%$^xyzabc
+123123xyzabc
+\\a\\b\\c\\dxyzabc
+xyzabc
+xyzabc
+中文xyzabc
+
+-- !const3 --
+\N
+ abc
+!@#@#$#^$%%$^!@#@#$#^$%%$^abc
+123123123123abc
+\\a\\b\\c\\d\\a\\b\\c\\dabc
+abc
+中文中文abc
+
diff --git
a/regression-test/data/query_p0/sql_functions/test_template_two_args.out
b/regression-test/data/query_p0/sql_functions/test_template_two_args.out
new file mode 100644
index 00000000000..e12f22f155c
--- /dev/null
+++ b/regression-test/data/query_p0/sql_functions/test_template_two_args.out
@@ -0,0 +1,279 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !empty_nullable --
+
+-- !empty_not_nullable --
+
+-- !empty_partial_nullable --
+
+-- !all_null --
+\N
+\N
+\N
+
+-- !nullable --
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+-0.008129902179943912
+-0.09966865249116204
+-0.7853981633974483
+-0.7853981633974483
+-0.7853981633974483
+-1.0E-100
+-1.0E-101
+-1.4711276743037345
+-1.5707963267948866
+-1.5707963267948957
+-1.5707963267948966
+-1.5707963267948966
+-1.5707963267948966
+-1.5707963267948966
+-1.5707963267948966
+-1.5707963267948966
+-1.5707963267948966
+-1.5707963267948966
+-1.5707963267948966
+-1.5707963267948966
+-1.5707963267948966
+-1.5707963267948966
+-1.5707963267948966
+-1.5707963267948966
+-1.5707963267948966
+-1.6704649792860586
+-2.356194490192345
+-2.356194490192345
+-2.356194490192345
+-3.0419240010986313
+-3.141592653589793
+-3.141592653589793
+-8.130079509533991E-4
+0.0
+0.0
+0.0
+0.0
+0.0
+0.0
+0.0
+0.0
+0.0
+0.0
+0.0
+0.0
+0.0
+0.0
+0.0
+0.0
+0.008129902179943912
+0.09966865249116204
+0.7853981633974483
+0.7853981633974483
+0.7853981633974483
+0.7853981633974483
+0.7853981633974483
+0.7853981633974483
+1.0E-100
+1.0E-100
+1.0E-101
+1.0E-115
+1.0E-14
+1.0E-15
+1.0E-200
+1.0E-85
+1.0E-99
+1.23E-98
+1.4711276743037345
+1.5626664246149526
+1.5699833188439432
+1.5707963267948866
+1.5707963267948957
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.57160933474585
+1.5789262289748405
+1.6704649792860586
+2.356194490192345
+2.356194490192345
+2.356194490192345
+3.0419240010986313
+3.1415926535897833
+3.1415926535897922
+3.141592653589793
+3.141592653589793
+3.141592653589793
+3.141592653589793
+3.141592653589793
+3.141592653589793
+3.141592653589793
+3.141592653589793
+3.141592653589793
+3.141592653589793
+3.141592653589793
+3.141592653589793
+3.141592653589793
+8.130079509533991E-4
+8.130081300813008E-103
+8.130081300813008E-18
+
+-- !not_nullable --
+-2.356194490192345
+-2.356194490192345
+-2.356194490192345
+0.0
+0.0
+0.0
+0.7853981633974483
+0.7853981633974483
+0.7853981633974483
+0.7853981633974483
+0.7853981633974483
+0.7853981633974483
+
+-- !partial_nullable --
+\N
+-2.356194490192345
+-2.356194490192345
+-2.356194490192345
+0.0
+0.0
+0.7853981633974483
+0.7853981633974483
+0.7853981633974483
+0.7853981633974483
+0.7853981633974483
+0.7853981633974483
+
+-- !nullable_no_null --
+-2.356194490192345
+-2.356194490192345
+-2.356194490192345
+0.0
+0.0
+0.0
+0.7853981633974483
+0.7853981633974483
+0.7853981633974483
+0.7853981633974483
+0.7853981633974483
+0.7853981633974483
+
+-- !const_nullable --
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+
+-- !partial_const_nullable --
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+
+-- !const_not_nullable --
+0.0049999583339583225
+0.0049999583339583225
+0.0049999583339583225
+0.0049999583339583225
+0.0049999583339583225
+0.0049999583339583225
+0.0049999583339583225
+0.0049999583339583225
+0.0049999583339583225
+0.0049999583339583225
+0.0049999583339583225
+0.0049999583339583225
+
+-- !const_other_nullable --
+\N
+0.08112239210090098
+1.0E-99
+1.4711276743037347
+1.5607966601082315
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5707963267948966
+1.5807959934815619
+1.6704649792860586
+3.141592653589793
+
+-- !const_other_not_nullable --
+-0.00999966668666524
+-0.09966865249116202
+-1.5707963267948966
+0.0
+0.0
+0.0
+0.00999966668666524
+0.09966865249116202
+1.0000000000000001E-16
+1.0E-101
+1.4896739346939956
+1.5707963267948966
+
+-- !const_nullable_no_null --
+1.5707963267948966
+
+-- !const_nullable_no_null_multirows --
+1.5707963267948966
+
+-- !const_partial_nullable_no_null --
+1.5707963267948966
+
diff --git
a/regression-test/suites/query_p0/sql_functions/test_template_one_arg.groovy
b/regression-test/suites/query_p0/sql_functions/test_template_one_arg.groovy
new file mode 100644
index 00000000000..078d100c70c
--- /dev/null
+++ b/regression-test/suites/query_p0/sql_functions/test_template_one_arg.groovy
@@ -0,0 +1,51 @@
+// 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.
+
+suite("test_template_one_arg") {
+ sql " drop table if exists test_asin"
+ sql """
+ create table test_asin (
+ k0 int,
+ a double not null,
+ b double null
+ )
+ DISTRIBUTED BY HASH(k0)
+ PROPERTIES
+ (
+ "replication_num" = "1"
+ );
+ """
+
+ order_qt_empty_nullable "select asin(b) from test_asin"
+ order_qt_empty_not_nullable "select asin(a) from test_asin"
+
+ sql "insert into test_asin values (1, 1, null), (1, 1, null), (1, 1, null)"
+ order_qt_all_null "select asin(b) from test_asin"
+
+ sql "truncate table test_asin"
+ sql """ insert into test_asin values (1, 1e-100, 1e-100), (2, -1e100,
-1e100), (3, 1e100, 1e100), (4, 1, 1), (5, -1, -1),
+ (6, 0, 0), (7, -0, -0), (8, 123, 123),
+ (9, 0.1, 0.1), (10, -0.1, -0.1), (11, 1e-15, 1e-15), (12, 0, null);
+ """
+
+ order_qt_nullable "select asin(b) from test_asin"
+ order_qt_not_nullable "select asin(a) from test_asin"
+ order_qt_nullable_no_null "select asin(nullable(a)) from test_asin"
+ order_qt_const_nullable "select asin(NULL) from test_asin" // choose some
cases to test const multi-rows
+ order_qt_const_not_nullable "select asin(0.5) from test_asin"
+ order_qt_const_nullable_no_null "select asin(nullable(0.5))"
+}
\ No newline at end of file
diff --git
a/regression-test/suites/query_p0/sql_functions/test_template_three_args.groovy
b/regression-test/suites/query_p0/sql_functions/test_template_three_args.groovy
new file mode 100644
index 00000000000..13de80a0393
--- /dev/null
+++
b/regression-test/suites/query_p0/sql_functions/test_template_three_args.groovy
@@ -0,0 +1,114 @@
+// 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.
+
+suite("test_template_three_args") {
+ // this table has nothing todo. just make it eaiser to generate query
+ sql " drop table if exists hits_three_args "
+ sql """ create table hits_three_args(
+ nothing boolean
+ )
+ properties("replication_num" = "1");
+ """
+ sql "insert into hits_three_args values(true);"
+
+ sql " drop table if exists arg1_three_args"
+ sql """
+ create table arg1_three_args (
+ k0 int,
+ a varchar not null,
+ b varchar null,
+ )
+ DISTRIBUTED BY HASH(k0)
+ PROPERTIES
+ (
+ "replication_num" = "1"
+ );
+ """
+
+ order_qt_empty_nullable "select concat(a, a, a) from arg1_three_args"
+ order_qt_empty_not_nullable "select concat(b, b, b) from arg1_three_args"
+ order_qt_empty_partial_nullable "select concat(a, b, b) from
arg1_three_args"
+
+ sql "insert into arg1_three_args values (1, 1, null), (1, 1, null), (1, 1,
null)"
+ order_qt_all_null "select concat(b, b, b ,b) from arg1_three_args"
+
+ sql "truncate table arg1_three_args"
+ sql """ insert into arg1_three_args values (1, "", ""), (2, "中文", "中文"),
(3, "123123", "123123"),
+ (4, "\\\\a\\\\b\\\\c\\\\d", "\\\\a\\\\b\\\\c\\\\d"),
+ (5, "!@#@#\$#^\$%%\$^", "!@#@#\$#^\$%%\$^"), (6, " ", " "),
+ (7, "", NULL);
+ """
+
+ order_qt_nullable """
+ SELECT concat(t.arg1_three_args, t.ARG2, t.ARG3) as result
+ FROM (
+ SELECT hits_three_args.nothing, TABLE1.arg1_three_args,
TABLE1.order1, TABLE2.ARG2, TABLE2.order2, TABLE3.ARG3, TABLE3.order3
+ FROM hits_three_args
+ CROSS JOIN (
+ SELECT b as arg1_three_args, k0 as order1
+ FROM arg1_three_args
+ ) as TABLE1
+ CROSS JOIN (
+ SELECT b as ARG2, k0 as order2
+ FROM arg1_three_args
+ ) as TABLE2
+ CROSS JOIN (
+ SELECT b as ARG3, k0 as order3
+ FROM arg1_three_args
+ ) as TABLE3
+ )t;
+ """
+
+ /// nullables
+ order_qt_not_nullable "select concat(a, a, a) from arg1_three_args"
+ order_qt_partial_nullable "select concat(a, b, b) from arg1_three_args"
+ order_qt_nullable_no_null "select concat(a, nullable(a), nullable(a)) from
arg1_three_args"
+ /// if you set `use_default_implementation_for_nulls` to false, add:
+ // order_qt_nullable1 " SELECT b as arg1_three_args...)as TABLE1 ...
SELECT a as arg1_three_args...)as TABLE1 ...
+ // order_qt_nullable2 " SELECT a as arg1_three_args...)as TABLE1 ...
SELECT b as arg1_three_args...)as TABLE1 ...
+
+ /// consts. most by BE-UT
+ order_qt_const_nullable "select concat(NULL, NULL, NULL) from
arg1_three_args"
+ order_qt_partial_const_nullable "select concat(NULL, b, b) from
arg1_three_args"
+ order_qt_const_not_nullable "select concat('a', 'b', 'c') from
arg1_three_args"
+ order_qt_const_other_nullable "select concat('x', b, b) from
arg1_three_args"
+ order_qt_const_other_not_nullable "select concat('x', 'x', a) from
arg1_three_args"
+ order_qt_const_nullable_no_null "select concat(nullable('abc'),
nullable('中文'), nullable('xxx'))"
+ order_qt_const_partial_nullable_no_null "select concat('xyz',
nullable('a'), nullable('a'))"
+ order_qt_const1 "select concat('xyz', a, b) from arg1_three_args"
+ order_qt_const12 "select concat('xyz', 'abc', b) from arg1_three_args"
+ order_qt_const23 "select concat(a, 'xyz', 'abc') from arg1_three_args"
+ order_qt_const3 "select concat(b, a, 'abc') from arg1_three_args"
+
+ /// folding
+ def re_fe
+ def re_be
+ def re_no_fold
+ def check_three_ways = { test_sql ->
+ re_fe = order_sql
"select/*+SET_VAR(enable_fold_constant_by_be=false)*/ ${test_sql}"
+ re_be = order_sql "select/*+SET_VAR(enable_fold_constant_by_be=true)*/
${test_sql}"
+ re_no_fold = order_sql
"select/*+SET_VAR(debug_skip_fold_constant=true)*/ ${test_sql}"
+ logger.info("check on sql \${test_sql}")
+ assertEquals(re_fe, re_be)
+ assertEquals(re_fe, re_no_fold)
+ }
+
+ check_three_ways "concat('', '', '')"
+ check_three_ways "concat('\\t\\t', '\\t\\t', '\\t\\t')"
+ check_three_ways "concat('中文', '中文', '中文')"
+ check_three_ways "concat('abcde', 'abcde', 'abcde')"
+}
\ No newline at end of file
diff --git
a/regression-test/suites/query_p0/sql_functions/test_template_two_args.groovy
b/regression-test/suites/query_p0/sql_functions/test_template_two_args.groovy
new file mode 100644
index 00000000000..9d7e2643eca
--- /dev/null
+++
b/regression-test/suites/query_p0/sql_functions/test_template_two_args.groovy
@@ -0,0 +1,108 @@
+// 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.
+
+suite("test_template_two_args") {
+ // this table has nothing todo. just make it eaiser to generate query
+ sql " drop table if exists hits_two_args "
+ sql """ create table hits_two_args(
+ nothing boolean
+ )
+ properties("replication_num" = "1");
+ """
+ sql "insert into hits_two_args values(true);"
+
+ sql " drop table if exists arg1_two_args"
+ sql """
+ create table arg1_two_args (
+ k0 int,
+ a double not null,
+ b double null,
+ )
+ DISTRIBUTED BY HASH(k0)
+ PROPERTIES
+ (
+ "replication_num" = "1"
+ );
+ """
+
+ order_qt_empty_nullable "select atan2(a, a) from arg1_two_args"
+ order_qt_empty_not_nullable "select atan2(b, b) from arg1_two_args"
+ order_qt_empty_partial_nullable "select atan2(a, b) from arg1_two_args"
+
+ sql "insert into arg1_two_args values (1, 1, null), (1, 1, null), (1, 1,
null)"
+ order_qt_all_null "select atan2(b, b) from arg1_two_args"
+
+ sql "truncate table arg1_two_args"
+ sql """ insert into arg1_two_args values (1, 1e-100, 1e-100), (2, -1e100,
-1e100), (3, 1e100, 1e100), (4, 1, 1), (5, -1, -1),
+ (6, 0, 0), (7, -0, -0), (8, 123, 123),
+ (9, 0.1, 0.1), (10, -0.1, -0.1), (11, 1e-15, 1e-15), (12, 0, null);
+ """
+
+ /// all values
+ order_qt_nullable """
+ SELECT atan2(t.arg1_two_args, t.ARG2) as result
+ FROM (
+ SELECT hits_two_args.nothing, TABLE1.arg1_two_args, TABLE1.order1,
TABLE2.ARG2, TABLE2.order2
+ FROM hits_two_args
+ CROSS JOIN (
+ SELECT b as arg1_two_args, k0 as order1
+ FROM arg1_two_args
+ ) as TABLE1
+ CROSS JOIN (
+ SELECT b as ARG2, k0 as order2
+ FROM arg1_two_args
+ ) as TABLE2
+ )t;
+ """
+
+ /// nullables
+ order_qt_not_nullable "select atan2(a, a) from arg1_two_args"
+ order_qt_partial_nullable "select atan2(a, b) from arg1_two_args"
+ order_qt_nullable_no_null "select atan2(a, nullable(a)) from arg1_two_args"
+ /// if you set `use_default_implementation_for_nulls` to false, add:
+ // order_qt_nullable1 " SELECT b as arg1_two_args...)as TABLE1 ... SELECT
a as arg1_two_args...)as TABLE1
+ // order_qt_nullable2 " SELECT a as arg1_two_args...)as TABLE1 ... SELECT
b as arg1_two_args...)as TABLE1
+
+ /// consts. most by BE-UT
+ order_qt_const_nullable "select atan2(NULL, NULL) from arg1_two_args"
+ order_qt_partial_const_nullable "select atan2(NULL, b) from arg1_two_args"
+ order_qt_const_not_nullable "select atan2(0.5, 100) from arg1_two_args"
+ order_qt_const_other_nullable "select atan2(10, b) from arg1_two_args"
+ order_qt_const_other_not_nullable "select atan2(a, 10) from arg1_two_args"
+ order_qt_const_nullable_no_null "select atan2(nullable(1e100),
nullable(1e-10))"
+ order_qt_const_nullable_no_null_multirows "select atan2(nullable(1e100),
nullable(1e-10))"
+ order_qt_const_partial_nullable_no_null "select atan2(1e100,
nullable(1e-10))"
+
+ /// folding
+ def re_fe
+ def re_be
+ def re_no_fold
+ def check_three_ways = { test_sql ->
+ re_fe = order_sql
"select/*+SET_VAR(enable_fold_constant_by_be=false)*/ ${test_sql}"
+ re_be = order_sql "select/*+SET_VAR(enable_fold_constant_by_be=true)*/
${test_sql}"
+ re_no_fold = order_sql
"select/*+SET_VAR(debug_skip_fold_constant=true)*/ ${test_sql}"
+ logger.info("check on sql ${test_sql}")
+ assertEquals(re_fe, re_be)
+ assertEquals(re_fe, re_no_fold)
+ }
+
+ check_three_ways "atan2(-1, -2)"
+ check_three_ways "atan2(-1e100, 3.14)"
+ check_three_ways "atan2(0, 0)"
+ check_three_ways "atan2(1e100, 1e100)"
+ check_three_ways "atan2(-0.5, 0.5)"
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]