summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_snowflake.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-07-24 08:03:45 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-07-24 08:03:45 +0000
commitca57dc468e5d8d0920e964d45ad25271ae6e633d (patch)
tree319d8bffcb5c3e9afe9e62beca9ef401480578d2 /tests/dialects/test_snowflake.py
parentAdding upstream version 17.4.1. (diff)
downloadsqlglot-ca57dc468e5d8d0920e964d45ad25271ae6e633d.tar.xz
sqlglot-ca57dc468e5d8d0920e964d45ad25271ae6e633d.zip
Adding upstream version 17.7.0.upstream/17.7.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_snowflake.py')
-rw-r--r--tests/dialects/test_snowflake.py54
1 files changed, 54 insertions, 0 deletions
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",