summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_snowflake.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-07-14 05:42:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-07-14 05:42:58 +0000
commitb0bf1ad1a196585c2d31bc38c554637fc4e2eec9 (patch)
tree2fe11cc45ff45169984b4dfb7b64661d1897ad9c /tests/dialects/test_snowflake.py
parentAdding upstream version 17.3.0. (diff)
downloadsqlglot-b0bf1ad1a196585c2d31bc38c554637fc4e2eec9.tar.xz
sqlglot-b0bf1ad1a196585c2d31bc38c554637fc4e2eec9.zip
Adding upstream version 17.4.1.upstream/17.4.1
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.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/dialects/test_snowflake.py b/tests/dialects/test_snowflake.py
index f7bab4d..e20045b 100644
--- a/tests/dialects/test_snowflake.py
+++ b/tests/dialects/test_snowflake.py
@@ -1,3 +1,5 @@
+from unittest import mock
+
from sqlglot import UnsupportedError, exp, parse_one
from tests.dialects.test_dialect import Validator
@@ -309,6 +311,7 @@ class TestSnowflake(Validator):
"SELECT IFF(TRUE, 'true', 'false')",
write={
"snowflake": "SELECT IFF(TRUE, 'true', 'false')",
+ "spark": "SELECT IF(TRUE, 'true', 'false')",
},
)
self.validate_all(
@@ -870,6 +873,46 @@ FROM persons AS p, LATERAL FLATTEN(input => p.c, path => 'contact') AS f, LATERA
self.assertIsInstance(ilike, exp.ILikeAny)
like.sql() # check that this doesn't raise
+ @mock.patch("sqlglot.generator.logger")
+ def test_regexp_substr(self, logger):
+ self.validate_all(
+ "REGEXP_SUBSTR(subject, pattern, pos, occ, params, group)",
+ write={
+ "bigquery": "REGEXP_EXTRACT(subject, pattern, pos, occ)",
+ "hive": "REGEXP_EXTRACT(subject, pattern, group)",
+ "presto": "REGEXP_EXTRACT(subject, pattern, group)",
+ "snowflake": "REGEXP_SUBSTR(subject, pattern, pos, occ, params, group)",
+ "spark": "REGEXP_EXTRACT(subject, pattern, group)",
+ },
+ )
+ self.validate_all(
+ "REGEXP_SUBSTR(subject, pattern)",
+ read={
+ "bigquery": "REGEXP_EXTRACT(subject, pattern)",
+ "hive": "REGEXP_EXTRACT(subject, pattern)",
+ "presto": "REGEXP_EXTRACT(subject, pattern)",
+ "spark": "REGEXP_EXTRACT(subject, pattern)",
+ },
+ write={
+ "bigquery": "REGEXP_EXTRACT(subject, pattern)",
+ "hive": "REGEXP_EXTRACT(subject, pattern)",
+ "presto": "REGEXP_EXTRACT(subject, pattern)",
+ "snowflake": "REGEXP_SUBSTR(subject, pattern)",
+ "spark": "REGEXP_EXTRACT(subject, pattern)",
+ },
+ )
+ self.validate_all(
+ "REGEXP_SUBSTR(subject, pattern, 1, 1, 'c', group)",
+ read={
+ "bigquery": "REGEXP_SUBSTR(subject, pattern, 1, 1, 'c', group)",
+ "duckdb": "REGEXP_EXTRACT(subject, pattern, group)",
+ "hive": "REGEXP_EXTRACT(subject, pattern, group)",
+ "presto": "REGEXP_EXTRACT(subject, pattern, group)",
+ "snowflake": "REGEXP_SUBSTR(subject, pattern, 1, 1, 'c', group)",
+ "spark": "REGEXP_EXTRACT(subject, pattern, group)",
+ },
+ )
+
def test_match_recognize(self):
for row in (
"ONE ROW PER MATCH",