From 8aa17c9395f441fb909cf55e5e5e1b63519a5a0c Mon Sep 17 00:00:00 2001 From: zhaochangle Date: Tue, 10 Dec 2024 23:43:18 +0800 Subject: [PATCH] 1 --- .../data/correctness/test_str_to_date.out | 45 ------------- .../math_functions/test_conv.out | 54 ---------------- .../nereids_syntax_p0/test_regexp_replace.out | 36 ----------- .../conditional_functions/test_json_parse.out | 63 ------------------- .../doris/regression/suite/Suite.groovy | 9 +++ .../correctness/test_str_to_date.groovy | 27 ++------ .../math_functions/test_conv.groovy | 28 ++------- .../test_regexp_replace.groovy | 24 ++----- .../test_json_parse.groovy | 30 +++------ .../string_functions/test_translate.groovy | 33 +++------- .../string_functions/test_trim_in.groovy | 36 ++++------- .../test_template_three_args.groovy | 20 ++---- .../test_template_two_args.groovy | 22 ++----- 13 files changed, 61 insertions(+), 366 deletions(-) diff --git a/regression-test/data/correctness/test_str_to_date.out b/regression-test/data/correctness/test_str_to_date.out index dfbb90e234b35c..f145ff9e4bedc8 100644 --- a/regression-test/data/correctness/test_str_to_date.out +++ b/regression-test/data/correctness/test_str_to_date.out @@ -53,48 +53,3 @@ 6 \N 7 \N --- !check_fe -- -2019-12-01 - --- !check_be -- -2019-12-01 - --- !check_no_fold -- -2019-12-01 - --- !check_fe -- -\N - --- !check_be -- -\N - --- !check_no_fold -- -\N - --- !check_fe -- -\N - --- !check_be -- -\N - --- !check_no_fold -- -\N - --- !check_fe -- -\N - --- !check_be -- -\N - --- !check_no_fold -- -\N - --- !check_fe -- -\N - --- !check_be -- -\N - --- !check_no_fold -- -\N - diff --git a/regression-test/data/nereids_p0/sql_functions/math_functions/test_conv.out b/regression-test/data/nereids_p0/sql_functions/math_functions/test_conv.out index db787d1daf1c1e..b10406e6456122 100644 --- a/regression-test/data/nereids_p0/sql_functions/math_functions/test_conv.out +++ b/regression-test/data/nereids_p0/sql_functions/math_functions/test_conv.out @@ -23,57 +23,3 @@ 10 2.789 11 3.14159 --- !check_fe -- -\N - --- !check_be -- -\N - --- !check_no_fold -- -\N - --- !check_fe -- -1111 - --- !check_be -- -1111 - --- !check_no_fold -- -1111 - --- !check_fe -- -\N - --- !check_be -- -\N - --- !check_no_fold -- -\N - --- !check_fe -- -\N - --- !check_be -- -\N - --- !check_no_fold -- -\N - --- !check_fe -- -\N - --- !check_be -- -\N - --- !check_no_fold -- -\N - --- !check_fe -- -1111011 - --- !check_be -- -1111011 - --- !check_no_fold -- -1111011 - diff --git a/regression-test/data/nereids_syntax_p0/test_regexp_replace.out b/regression-test/data/nereids_syntax_p0/test_regexp_replace.out index f06114138f0dcc..578937e0ca1236 100644 --- a/regression-test/data/nereids_syntax_p0/test_regexp_replace.out +++ b/regression-test/data/nereids_syntax_p0/test_regexp_replace.out @@ -5,42 +5,6 @@ abcxyz -- !replace_chinese -- 汉123 --- !check_fe -- -abcxyz - --- !check_be -- -abcxyz - --- !check_no_fold -- -abcxyz - --- !check_fe -- -\N - --- !check_be -- -\N - --- !check_no_fold -- -\N - --- !check_fe -- -\N - --- !check_be -- -\N - --- !check_no_fold -- -\N - --- !check_fe -- -\N - --- !check_be -- -\N - --- !check_no_fold -- -\N - -- !replace_in_table_chinese -- 1 abc123 2 汉汉汉汉汉456 diff --git a/regression-test/data/query_p0/sql_functions/conditional_functions/test_json_parse.out b/regression-test/data/query_p0/sql_functions/conditional_functions/test_json_parse.out index 05b650de68a545..a40cd6937d1560 100644 --- a/regression-test/data/query_p0/sql_functions/conditional_functions/test_json_parse.out +++ b/regression-test/data/query_p0/sql_functions/conditional_functions/test_json_parse.out @@ -28,66 +28,3 @@ null 8 123 9 [1,2,3] --- !check_fe -- -{"key":"value"} - --- !check_be -- -{"key":"value"} - --- !check_no_fold -- -{"key":"value"} - --- !check_fe -- -\N - --- !check_be -- -\N - --- !check_no_fold -- -\N - --- !check_fe -- -\N - --- !check_be -- -\N - --- !check_no_fold -- -\N - --- !check_fe -- -\N - --- !check_be -- -\N - --- !check_no_fold -- -\N - --- !check_fe -- -null - --- !check_be -- -null - --- !check_no_fold -- -null - --- !check_fe -- -123 - --- !check_be -- -123 - --- !check_no_fold -- -123 - --- !check_fe -- -[1,2,3] - --- !check_be -- -[1,2,3] - --- !check_no_fold -- -[1,2,3] - diff --git a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy index d622084c24bd82..59722d72d952fe 100644 --- a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy +++ b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy @@ -2714,4 +2714,13 @@ class Suite implements GroovyInterceptable { scpFiles("root", be_ip, udf_file_path, udf_file_path, false) } } + + def check_fold_consistency = { test_sql -> + def re_fe = order_sql "select /*+SET_VAR(enable_fold_constant_by_be=false)*/ ${test_sql}" + def re_be = order_sql "select /*+SET_VAR(enable_fold_constant_by_be=true)*/ ${test_sql}" + def re_no_fold = order_sql "select /*+SET_VAR(debug_skip_fold_constant=true)*/ ${test_sql}" + logger.info("check sql: ${test_sql}") + assertEquals(re_fe, re_be) + assertEquals(re_fe, re_no_fold) + } } diff --git a/regression-test/suites/correctness/test_str_to_date.groovy b/regression-test/suites/correctness/test_str_to_date.groovy index a45be14902ba56..75234b1f3b3afd 100644 --- a/regression-test/suites/correctness/test_str_to_date.groovy +++ b/regression-test/suites/correctness/test_str_to_date.groovy @@ -72,26 +72,9 @@ suite("test_str_to_date") { SELECT id, STR_TO_DATE(s1, s2) as result from test_str_to_date_db order by id; """ - 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 sql: ${test_sql}") - qt_check_fe "select /*+SET_VAR(enable_fold_constant_by_be=false)*/ ${test_sql}" - qt_check_be "select /*+SET_VAR(enable_fold_constant_by_be=true)*/ ${test_sql}" - qt_check_no_fold "select /*+SET_VAR(debug_skip_fold_constant=true)*/ ${test_sql}" - assertEquals(re_fe, re_be) - assertEquals(re_fe, re_no_fold) - } - - check_three_ways "STR_TO_DATE('2019-12-01', 'yyyy-MM-dd')" - check_three_ways "STR_TO_DATE(null, 'yyyy-MM-dd')" - check_three_ways "STR_TO_DATE('2019-12-01', null)" - check_three_ways "STR_TO_DATE(null, null)" - check_three_ways "STR_TO_DATE('无效日期', 'yyyy-MM-dd')" + check_fold_consistency "STR_TO_DATE('2019-12-01', 'yyyy-MM-dd')" + check_fold_consistency "STR_TO_DATE(null, 'yyyy-MM-dd')" + check_fold_consistency "STR_TO_DATE('2019-12-01', null)" + check_fold_consistency "STR_TO_DATE(null, null)" + check_fold_consistency "STR_TO_DATE('无效日期', 'yyyy-MM-dd')" } - diff --git a/regression-test/suites/nereids_p0/sql_functions/math_functions/test_conv.groovy b/regression-test/suites/nereids_p0/sql_functions/math_functions/test_conv.groovy index 631df018fbd726..1fa0bdcfc03ff9 100644 --- a/regression-test/suites/nereids_p0/sql_functions/math_functions/test_conv.groovy +++ b/regression-test/suites/nereids_p0/sql_functions/math_functions/test_conv.groovy @@ -36,26 +36,10 @@ suite("test_conv") { qt_select6 """ select conv(float_2,10,2), float_2 from test_tb_with_null; """ - 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}") - qt_check_fe "select/*+SET_VAR(enable_fold_constant_by_be=false)*/ ${test_sql}" - qt_check_be "select/*+SET_VAR(enable_fold_constant_by_be=true)*/ ${test_sql}" - qt_check_no_fold "select/*+SET_VAR(debug_skip_fold_constant=true)*/ ${test_sql}" - assertEquals(re_fe, re_be) - assertEquals(re_fe, re_no_fold) - } - - check_three_ways "conv(null, null, null)" - check_three_ways "conv(15, 10, 2)" - check_three_ways "conv(null, 10, 2)" - check_three_ways "conv(15, null, 2)" - check_three_ways "conv(15, 10, null)" - check_three_ways "conv('123', 10, 2)" + check_fold_consistency "conv(null, null, null)" + check_fold_consistency "conv(15, 10, 2)" + check_fold_consistency "conv(null, 10, 2)" + check_fold_consistency "conv(15, null, 2)" + check_fold_consistency "conv(15, 10, null)" + check_fold_consistency "conv('123', 10, 2)" } \ No newline at end of file diff --git a/regression-test/suites/nereids_syntax_p0/test_regexp_replace.groovy b/regression-test/suites/nereids_syntax_p0/test_regexp_replace.groovy index 33c6c845491c22..ff94b640022d6d 100644 --- a/regression-test/suites/nereids_syntax_p0/test_regexp_replace.groovy +++ b/regression-test/suites/nereids_syntax_p0/test_regexp_replace.groovy @@ -20,26 +20,10 @@ suite("test_regexp_replace") { qt_replace_chinese "SELECT regexp_replace('这是一个测试字符串123', '\\\\p{Han}+', '汉');" - 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}") - qt_check_fe "select/*+SET_VAR(enable_fold_constant_by_be=false)*/ ${test_sql}" - qt_check_be "select/*+SET_VAR(enable_fold_constant_by_be=true)*/ ${test_sql}" - qt_check_no_fold "select/*+SET_VAR(debug_skip_fold_constant=true)*/ ${test_sql}" - assertEquals(re_fe, re_be) - assertEquals(re_fe, re_no_fold) - } - - check_three_ways "regexp_replace('abc123', '123', 'xyz')" - check_three_ways "regexp_replace(null, 'abc', 'def')" - check_three_ways "regexp_replace('abc123', null, 'xyz')" - check_three_ways "regexp_replace('abc123', '123', null)" + check_fold_consistency "regexp_replace('abc123', '123', 'xyz')" + check_fold_consistency "regexp_replace(null, 'abc', 'def')" + check_fold_consistency "regexp_replace('abc123', null, 'xyz')" + check_fold_consistency "regexp_replace('abc123', '123', null)" sql """DROP TABLE IF EXISTS `test_table_for_regexp`;""" sql """CREATE TABLE test_table_for_regexp (id INT, name VARCHAR(100)) PROPERTIES ("replication_num"="1");""" diff --git a/regression-test/suites/query_p0/sql_functions/conditional_functions/test_json_parse.groovy b/regression-test/suites/query_p0/sql_functions/conditional_functions/test_json_parse.groovy index 11674695037218..a51138774dbc4b 100644 --- a/regression-test/suites/query_p0/sql_functions/conditional_functions/test_json_parse.groovy +++ b/regression-test/suites/query_p0/sql_functions/conditional_functions/test_json_parse.groovy @@ -42,28 +42,12 @@ suite("test_json_parse") { qt_parse_from_table "SELECT id, json_parse_error_to_null(json_str) FROM test_json_parse_table ORDER BY id;" - 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}") - qt_check_fe "SELECT /*+SET_VAR(enable_fold_constant_by_be=false)*/ ${test_sql};" - qt_check_be "SELECT /*+SET_VAR(enable_fold_constant_by_be=true)*/ ${test_sql};" - qt_check_no_fold "SELECT /*+SET_VAR(debug_skip_fold_constant=true)*/ ${test_sql};" - assertEquals(re_fe, re_be) - assertEquals(re_fe, re_no_fold) - } - - check_three_ways "json_parse_error_to_null('{\"key\": \"value\"}')" - check_three_ways "json_parse_error_to_null('Invalid JSON')" - check_three_ways "json_parse_error_to_null(NULL)" - check_three_ways "json_parse_error_to_null('')" - check_three_ways "json_parse_error_to_null('null')" - check_three_ways "json_parse_error_to_null('123')" - check_three_ways "json_parse_error_to_null('[1, 2, 3]')" + check_fold_consistency "json_parse_error_to_null('{\"key\": \"value\"}')" + check_fold_consistency "json_parse_error_to_null('Invalid JSON')" + check_fold_consistency "json_parse_error_to_null(NULL)" + check_fold_consistency "json_parse_error_to_null('')" + check_fold_consistency "json_parse_error_to_null('null')" + check_fold_consistency "json_parse_error_to_null('123')" + check_fold_consistency "json_parse_error_to_null('[1, 2, 3]')" } diff --git a/regression-test/suites/query_p0/sql_functions/string_functions/test_translate.groovy b/regression-test/suites/query_p0/sql_functions/string_functions/test_translate.groovy index e63f42ae5b4cf5..e6ba0ed44f390e 100644 --- a/regression-test/suites/query_p0/sql_functions/string_functions/test_translate.groovy +++ b/regression-test/suites/query_p0/sql_functions/string_functions/test_translate.groovy @@ -88,30 +88,15 @@ suite("test_translate") { order_qt_const3 "select translate(b, a, 'abc') from test_translate" /// folding - def re_fe - def re_be - def re_no_fold - def check_three_ways = { test_sql -> - sql "set enable_fold_constant_by_be=false;" - re_fe = order_sql "select ${test_sql}" - sql "set enable_fold_constant_by_be=true;" - re_be = order_sql "select ${test_sql}" - sql "set debug_skip_fold_constant=true;" - re_no_fold = order_sql "select ${test_sql}" - logger.info("check on sql \${test_sql}") - assertEquals(re_fe, re_be) - assertEquals(re_fe, re_no_fold) - } - - check_three_ways "translate('abcd', '', '');" - check_three_ways "translate('abcda', 'a', 'z');" - check_three_ways "translate('abcd', 'ac', 'z');" - check_three_ways "translate('abcd', 'aac', 'zq');" - check_three_ways "translate('abcd', 'aac', 'zqx');" - check_three_ways "translate('abcd', 'aac', '中文x');" - check_three_ways "translate('中文', '中', '文');" - check_three_ways "translate('中文', '中', 'a');" - check_three_ways "translate('\tt\tt\tt', '\t', 't');" + check_fold_consistency "translate('abcd', '', '');" + check_fold_consistency "translate('abcda', 'a', 'z');" + check_fold_consistency "translate('abcd', 'ac', 'z');" + check_fold_consistency "translate('abcd', 'aac', 'zq');" + check_fold_consistency "translate('abcd', 'aac', 'zqx');" + check_fold_consistency "translate('abcd', 'aac', '中文x');" + check_fold_consistency "translate('中文', '中', '文');" + check_fold_consistency "translate('中文', '中', 'a');" + check_fold_consistency "translate('\tt\tt\tt', '\t', 't');" order_qt_1 "select translate('abcd', '', '');" order_qt_2 "select translate('abcd', 'a', 'z')" diff --git a/regression-test/suites/query_p0/sql_functions/string_functions/test_trim_in.groovy b/regression-test/suites/query_p0/sql_functions/string_functions/test_trim_in.groovy index ae6790fb0693e1..bf04ebb454a982 100644 --- a/regression-test/suites/query_p0/sql_functions/string_functions/test_trim_in.groovy +++ b/regression-test/suites/query_p0/sql_functions/string_functions/test_trim_in.groovy @@ -82,30 +82,18 @@ suite("test_trim_in") { /// 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 "trim_in(' hello world ', ' ld')" - check_three_ways "ltrim_in(' hello world ', ' ld')" - check_three_ways "rtrim_in(' hello world ', ' ld')" - check_three_ways "trim_in(' hello world ', ' ehlowrd')" - check_three_ways "ltrim_in(' hello world ', ' ehlowrd')" - check_three_ways "rtrim_in(' hello world ', ' ehlowrd')" - check_three_ways "trim_in(' hello world ', '')" - check_three_ways "ltrim_in(' hello world ', '')" - check_three_ways "rtrim_in(' hello world ', '')" - check_three_ways "trim_in(' hello world ', ' ')" - check_three_ways "ltrim_in(' hello world ', ' ')" - check_three_ways "rtrim_in(' hello world ', ' ')" + check_fold_consistency "trim_in(' hello world ', ' ld')" + check_fold_consistency "ltrim_in(' hello world ', ' ld')" + check_fold_consistency "rtrim_in(' hello world ', ' ld')" + check_fold_consistency "trim_in(' hello world ', ' ehlowrd')" + check_fold_consistency "ltrim_in(' hello world ', ' ehlowrd')" + check_fold_consistency "rtrim_in(' hello world ', ' ehlowrd')" + check_fold_consistency "trim_in(' hello world ', '')" + check_fold_consistency "ltrim_in(' hello world ', '')" + check_fold_consistency "rtrim_in(' hello world ', '')" + check_fold_consistency "trim_in(' hello world ', ' ')" + check_fold_consistency "ltrim_in(' hello world ', ' ')" + check_fold_consistency "rtrim_in(' hello world ', ' ')" order_qt_1 "SELECT ltrim_in('');" order_qt_2 "SELECT ltrim_in(' ');" 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 index 13de80a0393024..64bb970c3f0cd6 100644 --- 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 @@ -95,20 +95,8 @@ suite("test_template_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')" + check_fold_consistency "concat('', '', '')" + check_fold_consistency "concat('\\t\\t', '\\t\\t', '\\t\\t')" + check_fold_consistency "concat('中文', '中文', '中文')" + check_fold_consistency "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 index 9d7e2643eca1c4..0794c79e817a40 100644 --- 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 @@ -88,21 +88,9 @@ suite("test_template_two_args") { 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)" + check_fold_consistency "atan2(-1, -2)" + check_fold_consistency "atan2(-1e100, 3.14)" + check_fold_consistency "atan2(0, 0)" + check_fold_consistency "atan2(1e100, 1e100)" + check_fold_consistency "atan2(-0.5, 0.5)" } \ No newline at end of file