summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_bigquery.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-19 13:44:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-19 13:44:59 +0000
commitef2db38de92f2329c1c366318bddfc7e3dee8415 (patch)
treedee41de1eb0e05f2f6805b77df41a71b3aa66ec2 /tests/dialects/test_bigquery.py
parentAdding upstream version 11.0.1. (diff)
downloadsqlglot-8ce0ff6e4c5539b72e44b3a6fe1713bd042f69a5.tar.xz
sqlglot-8ce0ff6e4c5539b72e44b3a6fe1713bd042f69a5.zip
Adding upstream version 11.1.3.upstream/11.1.3
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.py39
1 files changed, 27 insertions, 12 deletions
diff --git a/tests/dialects/test_bigquery.py b/tests/dialects/test_bigquery.py
index 241f496..7b18a6a 100644
--- a/tests/dialects/test_bigquery.py
+++ b/tests/dialects/test_bigquery.py
@@ -36,30 +36,33 @@ class TestBigQuery(Validator):
self.validate_all(
r'r"""/\*.*\*/"""',
write={
- "bigquery": r"'/\\*.*\\*/'",
+ "bigquery": r"'/\*.*\*/'",
"duckdb": r"'/\*.*\*/'",
"presto": r"'/\*.*\*/'",
- "hive": r"'/\\*.*\\*/'",
- "spark": r"'/\\*.*\\*/'",
+ "hive": r"'/\*.*\*/'",
+ "spark": r"'/\*.*\*/'",
},
)
+ with self.assertRaises(RuntimeError):
+ transpile("'\\'", read="bigquery")
+
self.validate_all(
- r"'\\'",
+ "'\\\\'",
write={
"bigquery": r"'\\'",
- "duckdb": r"'\'",
- "presto": r"'\'",
+ "duckdb": r"'\\'",
+ "presto": r"'\\'",
"hive": r"'\\'",
},
)
self.validate_all(
- R'R"""/\*.*\*/"""',
+ r'R"""/\*.*\*/"""',
write={
- "bigquery": R"'/\\*.*\\*/'",
- "duckdb": R"'/\*.*\*/'",
- "presto": R"'/\*.*\*/'",
- "hive": R"'/\\*.*\\*/'",
- "spark": R"'/\\*.*\\*/'",
+ "bigquery": r"'/\*.*\*/'",
+ "duckdb": r"'/\*.*\*/'",
+ "presto": r"'/\*.*\*/'",
+ "hive": r"'/\*.*\*/'",
+ "spark": r"'/\*.*\*/'",
},
)
self.validate_all(
@@ -228,6 +231,12 @@ class TestBigQuery(Validator):
},
)
self.validate_all(
+ "CREATE TABLE db.example_table (x int) PARTITION BY x cluster by x",
+ write={
+ "bigquery": "CREATE TABLE db.example_table (x INT64) PARTITION BY x CLUSTER BY x",
+ },
+ )
+ self.validate_all(
"SELECT * FROM a WHERE b IN UNNEST([1, 2, 3])",
write={
"bigquery": "SELECT * FROM a WHERE b IN UNNEST([1, 2, 3])",
@@ -324,6 +333,12 @@ class TestBigQuery(Validator):
"bigquery": "SELECT * FROM (SELECT a, b, c FROM test) PIVOT(SUM(b) AS d, COUNT(*) AS e FOR c IN ('x', 'y'))",
},
)
+ self.validate_all(
+ "SELECT REGEXP_EXTRACT(abc, 'pattern(group)') FROM table",
+ write={
+ "duckdb": "SELECT REGEXP_EXTRACT(abc, 'pattern(group)', 1) FROM table",
+ },
+ )
self.validate_identity("BEGIN A B C D E F")
self.validate_identity("BEGIN TRANSACTION")
self.validate_identity("COMMIT TRANSACTION")