1
0
Fork 0

Adding upstream version 23.16.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 21:34:56 +01:00
parent 9d7e0ff7aa
commit b6ae88ec81
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
93 changed files with 64106 additions and 59061 deletions

View file

@ -674,7 +674,9 @@ class TestExpressions(unittest.TestCase):
self.assertIsInstance(parse_one("STANDARD_HASH('hello', 'sha256')"), exp.StandardHash)
self.assertIsInstance(parse_one("DATE(foo)"), exp.Date)
self.assertIsInstance(parse_one("HEX(foo)"), exp.Hex)
self.assertIsInstance(parse_one("TO_HEX(foo)", read="bigquery"), exp.Hex)
self.assertIsInstance(parse_one("LOWER(HEX(foo))"), exp.LowerHex)
self.assertIsInstance(parse_one("TO_HEX(foo)", read="bigquery"), exp.LowerHex)
self.assertIsInstance(parse_one("UPPER(TO_HEX(foo))", read="bigquery"), exp.Hex)
self.assertIsInstance(parse_one("TO_HEX(MD5(foo))", read="bigquery"), exp.MD5)
self.assertIsInstance(parse_one("TRANSFORM(a, b)", read="spark"), exp.Transform)
self.assertIsInstance(parse_one("ADD_MONTHS(a, b)"), exp.AddMonths)
@ -834,21 +836,22 @@ class TestExpressions(unittest.TestCase):
b AS B,
c, /*comment*/
d AS D, -- another comment
CAST(x AS INT) -- final comment
CAST(x AS INT), -- yet another comment
y AND /* foo */ w AS E -- final comment
FROM foo
"""
expression = parse_one(sql)
self.assertEqual(
[e.alias_or_name for e in expression.expressions],
["a", "B", "c", "D", "x"],
["a", "B", "c", "D", "x", "E"],
)
self.assertEqual(
expression.sql(),
"SELECT a, b AS B, c /* comment */, d AS D /* another comment */, CAST(x AS INT) /* final comment */ FROM foo",
"SELECT a, b AS B, c /* comment */, d AS D /* another comment */, CAST(x AS INT) /* yet another comment */, y AND /* foo */ w AS E /* final comment */ FROM foo",
)
self.assertEqual(
expression.sql(comments=False),
"SELECT a, b AS B, c, d AS D, CAST(x AS INT) FROM foo",
"SELECT a, b AS B, c, d AS D, CAST(x AS INT), y AND w AS E FROM foo",
)
self.assertEqual(
expression.sql(pretty=True, comments=False),
@ -857,7 +860,8 @@ class TestExpressions(unittest.TestCase):
b AS B,
c,
d AS D,
CAST(x AS INT)
CAST(x AS INT),
y AND w AS E
FROM foo""",
)
self.assertEqual(
@ -867,7 +871,8 @@ FROM foo""",
b AS B,
c, /* comment */
d AS D, /* another comment */
CAST(x AS INT) /* final comment */
CAST(x AS INT), /* yet another comment */
y AND /* foo */ w AS E /* final comment */
FROM foo""",
)