From a43700fee43d5fa57ddbcc98f92ed866b1b9e3c0 Mon Sep 17 00:00:00 2001 From: joocer Date: Fri, 31 May 2024 14:51:23 +0100 Subject: [PATCH 1/2] 0.15.1 --- opteryx/__version__.py | 6 +++--- opteryx/functions/__init__.py | 1 + opteryx/functions/string_functions.py | 7 +++++++ tests/sql_battery/test_shapes_and_errors_battery.py | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/opteryx/__version__.py b/opteryx/__version__.py index f9e0512ce..12e91f9f4 100644 --- a/opteryx/__version__.py +++ b/opteryx/__version__.py @@ -27,9 +27,9 @@ class VersionStatus(Enum): _major = 0 -_minor = 16 -_revision = 0 -_status = VersionStatus.ALPHA +_minor = 15 +_revision = 1 +_status = VersionStatus.RELEASE __author__ = "@joocer" __version__ = f"{_major}.{_minor}.{_revision}" + ( diff --git a/opteryx/functions/__init__.py b/opteryx/functions/__init__.py index 172345ed7..b08cb3058 100644 --- a/opteryx/functions/__init__.py +++ b/opteryx/functions/__init__.py @@ -320,6 +320,7 @@ def select_values(boolean_arrays, value_arrays): "LEVENSHTEIN": string_functions.levenshtein, "SPLIT": string_functions.split, "MATCH_AGAINST": string_functions.match_against, + "REGEXP_REPLACE": string_functions.regex_replace, # HASHING & ENCODING "HASH": _iterate_single_parameter(lambda x: hex(CityHash64(str(x)))[2:]), diff --git a/opteryx/functions/string_functions.py b/opteryx/functions/string_functions.py index 671b5990b..95288c3b7 100644 --- a/opteryx/functions/string_functions.py +++ b/opteryx/functions/string_functions.py @@ -346,3 +346,10 @@ def match_against(arr, val): and set(tokenized_literal).issubset(tok) for tok in tokenized_strings ] + +def regex_replace(array, _pattern, _replacement): + + pattern = _pattern[0] + replacement = _replacement[0] + + return compute.replace_substring_regex(array, pattern, replacement) diff --git a/tests/sql_battery/test_shapes_and_errors_battery.py b/tests/sql_battery/test_shapes_and_errors_battery.py index 4e262700f..879b9280f 100644 --- a/tests/sql_battery/test_shapes_and_errors_battery.py +++ b/tests/sql_battery/test_shapes_and_errors_battery.py @@ -1347,6 +1347,7 @@ ("SELECT $missions.* FROM $missions INNER JOIN $user ON Mission = value WHERE attribute = 'membership'", 1, 8, None), ("SELECT * FROM $planets WHERE name = any(@@user_memberships)", 0, 20, None), ("SELECT name FROM sqlite.planets WHERE name = ANY(('Earth', 'Mars'))", 2, 1, None), + ("SELECT name FROM $planets WHERE REGEXP_REPLACE(name, '^E', 'G') == 'Garth'", 1, 1, None), # TEST FUNCTIONS ("EXECUTE PLANETS_BY_ID (id=1)", 1, 20, None), # simple case From 7056a3a9b0f01269ab1338e50b4e20e608cc4f63 Mon Sep 17 00:00:00 2001 From: XB500 Date: Fri, 31 May 2024 13:51:50 +0000 Subject: [PATCH 2/2] Opteryx Version 0.15.1 --- opteryx/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opteryx/__version__.py b/opteryx/__version__.py index 12e91f9f4..a2d6d3e0a 100644 --- a/opteryx/__version__.py +++ b/opteryx/__version__.py @@ -1,4 +1,4 @@ -__build__ = 540 +__build__ = 541 # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.