diff options
Diffstat (limited to 'tests/dialects/test_bigquery.py')
-rw-r--r-- | tests/dialects/test_bigquery.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/dialects/test_bigquery.py b/tests/dialects/test_bigquery.py index 1c8aa51..e05fca0 100644 --- a/tests/dialects/test_bigquery.py +++ b/tests/dialects/test_bigquery.py @@ -23,6 +23,14 @@ class TestBigQuery(Validator): self.validate_identity("SELECT b'abc'") self.validate_identity("""SELECT * FROM UNNEST(ARRAY<STRUCT<x INT64>>[1, 2])""") self.validate_identity("SELECT AS STRUCT 1 AS a, 2 AS b") + self.validate_all( + "SELECT AS STRUCT ARRAY(SELECT AS STRUCT b FROM x) AS y FROM z", + write={ + "": "SELECT AS STRUCT ARRAY(SELECT AS STRUCT b FROM x) AS y FROM z", + "bigquery": "SELECT AS STRUCT ARRAY(SELECT AS STRUCT b FROM x) AS y FROM z", + "duckdb": "SELECT {'y': ARRAY(SELECT {'b': b} FROM x)} FROM z", + }, + ) self.validate_identity("SELECT DISTINCT AS STRUCT 1 AS a, 2 AS b") self.validate_identity("SELECT AS VALUE STRUCT(1 AS a, 2 AS b)") self.validate_identity("SELECT STRUCT<ARRAY<STRING>>(['2023-01-17'])") @@ -117,6 +125,21 @@ class TestBigQuery(Validator): transpile("'\\'", read="bigquery") self.validate_all( + "r'x\\''", + write={ + "bigquery": "r'x\\''", + "hive": "'x\\''", + }, + ) + + self.validate_all( + "r'x\\y'", + write={ + "bigquery": "r'x\\y'", + "hive": "'x\\\\y'", + }, + ) + self.validate_all( "'\\\\'", write={ "bigquery": r"'\\'", @@ -458,6 +481,21 @@ class TestBigQuery(Validator): "SELECT * FROM UNNEST([1]) WITH OFFSET y", write={"bigquery": "SELECT * FROM UNNEST([1]) WITH OFFSET AS y"}, ) + self.validate_all( + "GENERATE_ARRAY(1, 4)", + read={"bigquery": "GENERATE_ARRAY(1, 4)"}, + write={"duckdb": "GENERATE_SERIES(1, 4)"}, + ) + self.validate_all( + "TO_JSON_STRING(x)", + read={"bigquery": "TO_JSON_STRING(x)"}, + write={ + "bigquery": "TO_JSON_STRING(x)", + "duckdb": "CAST(TO_JSON(x) AS TEXT)", + "presto": "JSON_FORMAT(x)", + "spark": "TO_JSON(x)", + }, + ) def test_user_defined_functions(self): self.validate_identity( |