Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore](test) Refactor fold constant test util in regression test #45266

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions regression-test/data/correctness/test_str_to_date.out
Original file line number Diff line number Diff line change
Expand Up @@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -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

36 changes: 0 additions & 36 deletions regression-test/data/nereids_syntax_p0/test_regexp_replace.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
27 changes: 5 additions & 22 deletions regression-test/suites/correctness/test_str_to_date.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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')"
}

Original file line number Diff line number Diff line change
Expand Up @@ -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)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]')"
}

Loading
Loading