Skip to content

Commit

Permalink
trino: Transpile regexp_contains
Browse files Browse the repository at this point in the history
  • Loading branch information
emk committed Feb 22, 2024
1 parent 3ba375a commit bb56224
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/drivers/trino/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ static FUNCTION_NAMES: phf::Map<&'static str, &'static str> = phf::phf_map! {
"CURRENT_DATETIME" => "CURRENT_TIMESTAMP",
"DATETIME" => "memory.joinery_compat.DATETIME",
"GENERATE_UUID" => "memory.joinery_compat.GENERATE_UUID",
"REGEXP_CONTAINS" => "REGEXP_LIKE",
"SHA256" => "memory.joinery_compat.SHA256_COMPAT",
"SUBSTR" => "memory.joinery_compat.SUBSTR_COMPAT",
"TO_HEX" => "memory.joinery_compat.TO_HEX_COMPAT",
Expand Down
1 change: 1 addition & 0 deletions src/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ MIN = FnAgg(Agg<INT64>) -> INT64 | FnAgg(Agg<FLOAT64>) -> FLOAT64;
MOD = Fn(INT64, INT64) -> INT64;
RAND = Fn() -> FLOAT64;
RANK = FnOver() -> INT64;
REGEXP_CONTAINS = Fn(STRING, STRING) -> BOOL;
REGEXP_EXTRACT = Fn(STRING, STRING) -> STRING;
REGEXP_REPLACE = Fn(STRING, STRING, STRING) -> STRING;
REPLACE = Fn(STRING, STRING, STRING) -> STRING;
Expand Down
9 changes: 7 additions & 2 deletions tests/sql/functions/simple/regexp.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@
CREATE OR REPLACE TABLE __result1 AS
SELECT
REGEXP_REPLACE('foo', r'oo', 'ee') AS replaced,
REGEXP_EXTRACT('foobar', r'o+') AS extracted;
REGEXP_EXTRACT('foobar', r'o+') AS extracted,
REGEXP_CONTAINS('foobar', r'o+') AS contains_true,
REGEXP_CONTAINS('foobar', r'z+') AS contains_false;

CREATE OR REPLACE TABLE __expected1 (
replaced STRING,
extracted STRING,
contains_true BOOL,
contains_false BOOL,
);
INSERT INTO __expected1 VALUES ('fee', 'oo');
INSERT INTO __expected1 VALUES ('fee', 'oo', true, false);

0 comments on commit bb56224

Please sign in to comment.