From 36db14f4c6c28209371d563d76697df0172e337f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 24 Jul 2023 10:03:48 +0200 Subject: Merging upstream version 17.7.0. Signed-off-by: Daniel Baumann --- tests/dialects/test_snowflake.py | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'tests/dialects/test_snowflake.py') diff --git a/tests/dialects/test_snowflake.py b/tests/dialects/test_snowflake.py index e20045b..82762e8 100644 --- a/tests/dialects/test_snowflake.py +++ b/tests/dialects/test_snowflake.py @@ -386,7 +386,9 @@ class TestSnowflake(Validator): self.validate_all( "SELECT RLIKE(a, b)", write={ + "hive": "SELECT a RLIKE b", "snowflake": "SELECT REGEXP_LIKE(a, b)", + "spark": "SELECT a RLIKE b", }, ) self.validate_all( @@ -913,6 +915,58 @@ FROM persons AS p, LATERAL FLATTEN(input => p.c, path => 'contact') AS f, LATERA }, ) + @mock.patch("sqlglot.generator.logger") + def test_regexp_replace(self, logger): + self.validate_all( + "REGEXP_REPLACE(subject, pattern)", + write={ + "bigquery": "REGEXP_REPLACE(subject, pattern, '')", + "duckdb": "REGEXP_REPLACE(subject, pattern, '')", + "hive": "REGEXP_REPLACE(subject, pattern, '')", + "snowflake": "REGEXP_REPLACE(subject, pattern, '')", + "spark": "REGEXP_REPLACE(subject, pattern, '')", + }, + ) + self.validate_all( + "REGEXP_REPLACE(subject, pattern, replacement)", + read={ + "bigquery": "REGEXP_REPLACE(subject, pattern, replacement)", + "duckdb": "REGEXP_REPLACE(subject, pattern, replacement)", + "hive": "REGEXP_REPLACE(subject, pattern, replacement)", + "spark": "REGEXP_REPLACE(subject, pattern, replacement)", + }, + write={ + "bigquery": "REGEXP_REPLACE(subject, pattern, replacement)", + "duckdb": "REGEXP_REPLACE(subject, pattern, replacement)", + "hive": "REGEXP_REPLACE(subject, pattern, replacement)", + "snowflake": "REGEXP_REPLACE(subject, pattern, replacement)", + "spark": "REGEXP_REPLACE(subject, pattern, replacement)", + }, + ) + self.validate_all( + "REGEXP_REPLACE(subject, pattern, replacement, position)", + read={ + "spark": "REGEXP_REPLACE(subject, pattern, replacement, position)", + }, + write={ + "bigquery": "REGEXP_REPLACE(subject, pattern, replacement)", + "duckdb": "REGEXP_REPLACE(subject, pattern, replacement)", + "hive": "REGEXP_REPLACE(subject, pattern, replacement)", + "snowflake": "REGEXP_REPLACE(subject, pattern, replacement, position)", + "spark": "REGEXP_REPLACE(subject, pattern, replacement, position)", + }, + ) + self.validate_all( + "REGEXP_REPLACE(subject, pattern, replacement, position, occurrence, parameters)", + write={ + "bigquery": "REGEXP_REPLACE(subject, pattern, replacement)", + "duckdb": "REGEXP_REPLACE(subject, pattern, replacement)", + "hive": "REGEXP_REPLACE(subject, pattern, replacement)", + "snowflake": "REGEXP_REPLACE(subject, pattern, replacement, position, occurrence, parameters)", + "spark": "REGEXP_REPLACE(subject, pattern, replacement, position)", + }, + ) + def test_match_recognize(self): for row in ( "ONE ROW PER MATCH", -- cgit v1.2.3