diff options
Diffstat (limited to 'tests/dialects/test_duckdb.py')
-rw-r--r-- | tests/dialects/test_duckdb.py | 45 |
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( |