diff options
Diffstat (limited to 'tests/dialects/test_bigquery.py')
-rw-r--r-- | tests/dialects/test_bigquery.py | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/tests/dialects/test_bigquery.py b/tests/dialects/test_bigquery.py index f881385..366cade 100644 --- a/tests/dialects/test_bigquery.py +++ b/tests/dialects/test_bigquery.py @@ -1640,6 +1640,11 @@ WHERE }, ) + self.validate_identity( + "SELECT * FROM ML.FEATURES_AT_TIME(TABLE mydataset.feature_table, time => '2022-06-11 10:00:00+00', num_rows => 1, ignore_feature_nulls => TRUE)" + ) + self.validate_identity("SELECT * FROM ML.FEATURES_AT_TIME((SELECT 1), num_rows => 1)") + def test_errors(self): with self.assertRaises(TokenError): transpile("'\\'", read="bigquery") @@ -2145,27 +2150,37 @@ OPTIONS ( }, ) - self.validate_all( - f"""SELECT {func}('{{"name": "Jakob", "age": "6"}}', '$.age')""", - write={ - "bigquery": f"""SELECT {func}('{{"name": "Jakob", "age": "6"}}', '$.age')""", - "duckdb": """SELECT '{"name": "Jakob", "age": "6"}' ->> '$.age'""", - "snowflake": """SELECT JSON_EXTRACT_PATH_TEXT('{"name": "Jakob", "age": "6"}', 'age')""", - }, - ) + sql = f"""SELECT {func}('{{"name": "Jakob", "age": "6"}}', '$.age')""" + self.validate_all( + sql, + write={ + "bigquery": sql, + "duckdb": """SELECT '{"name": "Jakob", "age": "6"}' ->> '$.age'""", + "snowflake": """SELECT JSON_EXTRACT_PATH_TEXT('{"name": "Jakob", "age": "6"}', 'age')""", + }, + ) + + self.assertEqual( + self.parse_one(sql).sql("bigquery", normalize_functions="upper"), sql + ) def test_json_extract_array(self): for func in ("JSON_QUERY_ARRAY", "JSON_EXTRACT_ARRAY"): with self.subTest(f"Testing BigQuery's {func}"): + sql = f"""SELECT {func}('{{"fruits": [1, "oranges"]}}', '$.fruits')""" self.validate_all( - f"""SELECT {func}('{{"fruits": [1, "oranges"]}}', '$.fruits')""", + sql, write={ - "bigquery": f"""SELECT {func}('{{"fruits": [1, "oranges"]}}', '$.fruits')""", + "bigquery": sql, "duckdb": """SELECT CAST('{"fruits": [1, "oranges"]}' -> '$.fruits' AS JSON[])""", "snowflake": """SELECT TRANSFORM(GET_PATH(PARSE_JSON('{"fruits": [1, "oranges"]}'), 'fruits'), x -> PARSE_JSON(TO_JSON(x)))""", }, ) + self.assertEqual( + self.parse_one(sql).sql("bigquery", normalize_functions="upper"), sql + ) + def test_unix_seconds(self): self.validate_all( "SELECT UNIX_SECONDS('2008-12-25 15:30:00+00')", |