summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_bigquery.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-22 18:53:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-22 18:53:31 +0000
commit20d090151fbc2e75394fc456f49f0078e59752d8 (patch)
tree084494962f092ff80f5ef8fdba1b917206abbc83 /tests/dialects/test_bigquery.py
parentAdding upstream version 16.2.1. (diff)
downloadsqlglot-20d090151fbc2e75394fc456f49f0078e59752d8.tar.xz
sqlglot-20d090151fbc2e75394fc456f49f0078e59752d8.zip
Adding upstream version 16.4.0.upstream/16.4.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_bigquery.py')
-rw-r--r--tests/dialects/test_bigquery.py38
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(