From 13fada231c96db7c8f05ef7e9d8d31a63e9d7ad5 Mon Sep 17 00:00:00 2001 From: khamitovdr Date: Tue, 1 Apr 2025 13:36:28 +0300 Subject: [PATCH 1/4] update --- .../dl_formula_testing/testcases/functions_string.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/dl_formula_testing/dl_formula_testing/testcases/functions_string.py b/lib/dl_formula_testing/dl_formula_testing/testcases/functions_string.py index e1332d4201..37c47d3dbf 100644 --- a/lib/dl_formula_testing/dl_formula_testing/testcases/functions_string.py +++ b/lib/dl_formula_testing/dl_formula_testing/testcases/functions_string.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from typing import ( Any, ClassVar, @@ -75,6 +73,7 @@ def test_find(self, dbe: DbEvaluator) -> None: assert dbe.eval('FIND("Lorem ipsum dolor sit amet", "abc")') == 0 assert dbe.eval('FIND("Карл у Клары украл кораллы", "рал")') == 16 assert dbe.eval('FIND("Lorem ipsum dolor sit amet", "or", 7)') == 16 + assert dbe.eval('FIND("Lorem ipsum dolor sit amet", "Lor", 7)') == 0 assert dbe.eval('FIND("Карл у Клары украл кораллы", "рал", 18)') == 22 def test_left_right(self, dbe: DbEvaluator) -> None: @@ -130,9 +129,10 @@ def test_regexp_extract(self, dbe: DbEvaluator, data_table: sa.Table) -> None: def test_regexp_extract_all(self, dbe: DbEvaluator, data_table: sa.Table) -> None: if not self.supports_regex_extract_all: pytest.skip() + assert dbe.eval("REGEXP_EXTRACT_ALL('100-200, 300-400', '(\\d+)-(\\d+)')") in ("['100','300']", ["100", "300"]) - assert dbe.eval("REGEXP_EXTRACT_ALL('нет_цифр', '(\\d+)-(\\d+)')") in ("[]", None) - assert to_str(dbe.eval('REGEXP_EXTRACT_ALL([str_null_value], "or..")', from_=data_table)) in (None, "[]") + assert dbe.eval("REGEXP_EXTRACT_ALL('нет_цифр', '(\\d+)-(\\d+)')") in ("[]", [], None) + assert to_str(dbe.eval('REGEXP_EXTRACT_ALL([str_null_value], "or..")', from_=data_table)) in (None, [], "[]") assert dbe.eval("REGEXP_EXTRACT_ALL('1а2б3в4', '\\d+([а-я]*)\\d+')") in ("['а','в']", ["а", "в"]) def test_regexp_extract_nth(self, dbe: DbEvaluator, data_table: sa.Table) -> None: @@ -171,13 +171,14 @@ def test_space(self, dbe: DbEvaluator) -> None: assert ( to_str(dbe.eval("SPACE(4)")) == " " ) # SPACE() is evaluated in Python rather than in the DB, - assert to_str(dbe.eval("SPACE(2 + 2)")) == " " # while this version actually uses the DB function(s) + assert to_str(dbe.eval("SPACE(LEN('aaaa'))")) == " " # while this version actually uses the DB function(s) def test_split_3(self, dbe: DbEvaluator, data_table: sa.Table) -> None: if not self.supports_split_3: pytest.skip() assert to_str(dbe.eval('SPLIT("Lorem ipsum dolor sit amet", " ", 3)')) == "dolor" + assert to_str(dbe.eval('SPLIT("Lorem ipsum dolor sit amet", " ", -2)')) == "sit" assert to_str(dbe.eval('SPLIT([str_null_value], " ", 3)', from_=data_table)) in (None, "") def test_split_1_2(self, dbe: DbEvaluator, data_table: sa.Table) -> None: From 96bd564dd1dc881e4863b1a65dd2f99365dd5cd1 Mon Sep 17 00:00:00 2001 From: khamitovdr Date: Mon, 7 Apr 2025 21:24:20 +0300 Subject: [PATCH 2/4] Roll back trino-related stuff --- .../dl_formula_testing/testcases/functions_string.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/dl_formula_testing/dl_formula_testing/testcases/functions_string.py b/lib/dl_formula_testing/dl_formula_testing/testcases/functions_string.py index 37c47d3dbf..425afb6a96 100644 --- a/lib/dl_formula_testing/dl_formula_testing/testcases/functions_string.py +++ b/lib/dl_formula_testing/dl_formula_testing/testcases/functions_string.py @@ -73,7 +73,6 @@ def test_find(self, dbe: DbEvaluator) -> None: assert dbe.eval('FIND("Lorem ipsum dolor sit amet", "abc")') == 0 assert dbe.eval('FIND("Карл у Клары украл кораллы", "рал")') == 16 assert dbe.eval('FIND("Lorem ipsum dolor sit amet", "or", 7)') == 16 - assert dbe.eval('FIND("Lorem ipsum dolor sit amet", "Lor", 7)') == 0 assert dbe.eval('FIND("Карл у Клары украл кораллы", "рал", 18)') == 22 def test_left_right(self, dbe: DbEvaluator) -> None: @@ -131,8 +130,8 @@ def test_regexp_extract_all(self, dbe: DbEvaluator, data_table: sa.Table) -> Non pytest.skip() assert dbe.eval("REGEXP_EXTRACT_ALL('100-200, 300-400', '(\\d+)-(\\d+)')") in ("['100','300']", ["100", "300"]) - assert dbe.eval("REGEXP_EXTRACT_ALL('нет_цифр', '(\\d+)-(\\d+)')") in ("[]", [], None) - assert to_str(dbe.eval('REGEXP_EXTRACT_ALL([str_null_value], "or..")', from_=data_table)) in (None, [], "[]") + assert dbe.eval("REGEXP_EXTRACT_ALL('нет_цифр', '(\\d+)-(\\d+)')") in ("[]", None) + assert to_str(dbe.eval('REGEXP_EXTRACT_ALL([str_null_value], "or..")', from_=data_table)) in (None, "[]") assert dbe.eval("REGEXP_EXTRACT_ALL('1а2б3в4', '\\d+([а-я]*)\\d+')") in ("['а','в']", ["а", "в"]) def test_regexp_extract_nth(self, dbe: DbEvaluator, data_table: sa.Table) -> None: From dfe61d59b0ae348ebebcd58b06920e996c05cd67 Mon Sep 17 00:00:00 2001 From: khamitovdr Date: Mon, 7 Apr 2025 21:33:14 +0300 Subject: [PATCH 3/4] moved SPACE-related stuff to separate PR --- .../dl_formula_testing/testcases/functions_string.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/dl_formula_testing/dl_formula_testing/testcases/functions_string.py b/lib/dl_formula_testing/dl_formula_testing/testcases/functions_string.py index 425afb6a96..a5cbd32fc4 100644 --- a/lib/dl_formula_testing/dl_formula_testing/testcases/functions_string.py +++ b/lib/dl_formula_testing/dl_formula_testing/testcases/functions_string.py @@ -128,7 +128,6 @@ def test_regexp_extract(self, dbe: DbEvaluator, data_table: sa.Table) -> None: def test_regexp_extract_all(self, dbe: DbEvaluator, data_table: sa.Table) -> None: if not self.supports_regex_extract_all: pytest.skip() - assert dbe.eval("REGEXP_EXTRACT_ALL('100-200, 300-400', '(\\d+)-(\\d+)')") in ("['100','300']", ["100", "300"]) assert dbe.eval("REGEXP_EXTRACT_ALL('нет_цифр', '(\\d+)-(\\d+)')") in ("[]", None) assert to_str(dbe.eval('REGEXP_EXTRACT_ALL([str_null_value], "or..")', from_=data_table)) in (None, "[]") @@ -170,7 +169,7 @@ def test_space(self, dbe: DbEvaluator) -> None: assert ( to_str(dbe.eval("SPACE(4)")) == " " ) # SPACE() is evaluated in Python rather than in the DB, - assert to_str(dbe.eval("SPACE(LEN('aaaa'))")) == " " # while this version actually uses the DB function(s) + assert to_str(dbe.eval("SPACE(2 + 2)")) == " " # while this version actually uses the DB function(s) def test_split_3(self, dbe: DbEvaluator, data_table: sa.Table) -> None: if not self.supports_split_3: From d6481cae7e598c4556fc4d1f4a8e7f8a406d76d6 Mon Sep 17 00:00:00 2001 From: khamitovdr Date: Mon, 7 Apr 2025 21:40:59 +0300 Subject: [PATCH 4/4] fixed in separate PR --- .../dl_formula_testing/testcases/functions_string.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/dl_formula_testing/dl_formula_testing/testcases/functions_string.py b/lib/dl_formula_testing/dl_formula_testing/testcases/functions_string.py index a5cbd32fc4..823db60612 100644 --- a/lib/dl_formula_testing/dl_formula_testing/testcases/functions_string.py +++ b/lib/dl_formula_testing/dl_formula_testing/testcases/functions_string.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import ( Any, ClassVar,