1
0
Fork 0

Adding upstream version 25.32.1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 21:57:52 +01:00
parent 24751d63a1
commit 0375f9323c
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
51 changed files with 65446 additions and 62526 deletions

View file

@ -1574,14 +1574,6 @@ WHERE
"snowflake": "IFF((y) <> 0, (x) / (y), NULL)",
},
)
self.validate_all(
"""SELECT JSON_QUERY('{"class": {"students": []}}', '$.class')""",
write={
"bigquery": """SELECT JSON_QUERY('{"class": {"students": []}}', '$.class')""",
"duckdb": """SELECT '{"class": {"students": []}}' -> '$.class'""",
"snowflake": """SELECT GET_PATH(PARSE_JSON('{"class": {"students": []}}'), 'class')""",
},
)
self.validate_all(
"""SELECT JSON_VALUE_ARRAY('{"arr": [1, "a"]}', '$.arr')""",
write={
@ -2139,7 +2131,16 @@ OPTIONS (
},
)
def test_json_extract_scalar(self):
def test_json_extract(self):
self.validate_all(
"""SELECT JSON_QUERY('{"class": {"students": []}}', '$.class')""",
write={
"bigquery": """SELECT JSON_QUERY('{"class": {"students": []}}', '$.class')""",
"duckdb": """SELECT '{"class": {"students": []}}' -> '$.class'""",
"snowflake": """SELECT GET_PATH(PARSE_JSON('{"class": {"students": []}}'), 'class')""",
},
)
for func in ("JSON_EXTRACT_SCALAR", "JSON_VALUE"):
with self.subTest(f"Testing BigQuery's {func}"):
self.validate_all(
@ -2164,6 +2165,18 @@ OPTIONS (
self.parse_one(sql).sql("bigquery", normalize_functions="upper"), sql
)
# Test double quote escaping
for func in ("JSON_VALUE", "JSON_QUERY", "JSON_QUERY_ARRAY"):
self.validate_identity(
f"{func}(doc, '$. a b c .d')", f"""{func}(doc, '$." a b c ".d')"""
)
# Test single quote & bracket escaping
for func in ("JSON_EXTRACT", "JSON_EXTRACT_SCALAR", "JSON_EXTRACT_ARRAY"):
self.validate_identity(
f"{func}(doc, '$. a b c .d')", f"""{func}(doc, '$[\\' a b c \\'].d')"""
)
def test_json_extract_array(self):
for func in ("JSON_QUERY_ARRAY", "JSON_EXTRACT_ARRAY"):
with self.subTest(f"Testing BigQuery's {func}"):

View file

@ -118,6 +118,13 @@ class TestMySQL(Validator):
"CREATE TABLE `foo` (a VARCHAR(10), INDEX idx_a (a DESC))",
)
self.validate_all(
"insert into t(i) values (default)",
write={
"duckdb": "INSERT INTO t (i) VALUES (DEFAULT)",
"mysql": "INSERT INTO t (i) VALUES (DEFAULT)",
},
)
self.validate_all(
"CREATE TABLE t (id INT UNSIGNED)",
write={