summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_duckdb.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-09 08:14:01 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-09 08:14:01 +0000
commit705d595e4873c2b13dd98d4614ca729f4d4ed81c (patch)
treed42152d0d58a859ebf2eff8e5688f988f376703d /tests/dialects/test_duckdb.py
parentReleasing debian version 25.26.0-1. (diff)
downloadsqlglot-705d595e4873c2b13dd98d4614ca729f4d4ed81c.tar.xz
sqlglot-705d595e4873c2b13dd98d4614ca729f4d4ed81c.zip
Merging upstream version 25.29.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_duckdb.py')
-rw-r--r--tests/dialects/test_duckdb.py45
1 files changed, 31 insertions, 14 deletions
diff --git a/tests/dialects/test_duckdb.py b/tests/dialects/test_duckdb.py
index 1f8fb81..b59ac9f 100644
--- a/tests/dialects/test_duckdb.py
+++ b/tests/dialects/test_duckdb.py
@@ -620,12 +620,6 @@ class TestDuckDB(Validator):
},
)
self.validate_all(
- "IF((y) <> 0, (x) / (y), NULL)",
- read={
- "bigquery": "SAFE_DIVIDE(x, y)",
- },
- )
- self.validate_all(
"STRUCT_PACK(x := 1, y := '2')",
write={
"bigquery": "STRUCT(1 AS x, '2' AS y)",
@@ -758,16 +752,9 @@ class TestDuckDB(Validator):
"snowflake": "SELECT PERCENTILE_DISC(q) WITHIN GROUP (ORDER BY x) FROM t",
},
)
- self.validate_all(
- "SELECT MEDIAN(x) FROM t",
- write={
- "duckdb": "SELECT QUANTILE_CONT(x, 0.5) FROM t",
- "postgres": "SELECT PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY x) FROM t",
- "snowflake": "SELECT PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY x) FROM t",
- },
- )
with self.assertRaises(UnsupportedError):
+ # bq has the position arg, but duckdb doesn't
transpile(
"SELECT REGEXP_EXTRACT(a, 'pattern', 1) from table",
read="bigquery",
@@ -775,6 +762,36 @@ class TestDuckDB(Validator):
unsupported_level=ErrorLevel.IMMEDIATE,
)
+ self.validate_all(
+ "SELECT REGEXP_EXTRACT(a, 'pattern') FROM t",
+ read={
+ "duckdb": "SELECT REGEXP_EXTRACT(a, 'pattern') FROM t",
+ "bigquery": "SELECT REGEXP_EXTRACT(a, 'pattern') FROM t",
+ "snowflake": "SELECT REGEXP_SUBSTR(a, 'pattern') FROM t",
+ },
+ write={
+ "duckdb": "SELECT REGEXP_EXTRACT(a, 'pattern') FROM t",
+ "bigquery": "SELECT REGEXP_EXTRACT(a, 'pattern') FROM t",
+ "snowflake": "SELECT REGEXP_SUBSTR(a, 'pattern') FROM t",
+ },
+ )
+ self.validate_all(
+ "SELECT REGEXP_EXTRACT(a, 'pattern', 2, 'i') FROM t",
+ read={
+ "snowflake": "SELECT REGEXP_SUBSTR(a, 'pattern', 1, 1, 'i', 2) FROM t",
+ },
+ write={
+ "duckdb": "SELECT REGEXP_EXTRACT(a, 'pattern', 2, 'i') FROM t",
+ "snowflake": "SELECT REGEXP_SUBSTR(a, 'pattern', 1, 1, 'i', 2) FROM t",
+ },
+ )
+ self.validate_identity(
+ "SELECT REGEXP_EXTRACT(a, 'pattern', 0)",
+ "SELECT REGEXP_EXTRACT(a, 'pattern')",
+ )
+ self.validate_identity("SELECT REGEXP_EXTRACT(a, 'pattern', 0, 'i')")
+ self.validate_identity("SELECT REGEXP_EXTRACT(a, 'pattern', 1, 'i')")
+
self.validate_identity("SELECT ISNAN(x)")
self.validate_all(