summaryrefslogtreecommitdiffstats
path: root/tests/test_expressions.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 05:35:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 05:35:50 +0000
commit8f1b330983bddb35e2ec61a5667a84318bad88ef (patch)
tree32b74e964839c34014d31ec828fc6521323b9edc /tests/test_expressions.py
parentAdding upstream version 23.13.7. (diff)
downloadsqlglot-8f1b330983bddb35e2ec61a5667a84318bad88ef.tar.xz
sqlglot-8f1b330983bddb35e2ec61a5667a84318bad88ef.zip
Adding upstream version 23.16.0.upstream/23.16.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_expressions.py')
-rw-r--r--tests/test_expressions.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/tests/test_expressions.py b/tests/test_expressions.py
index 81cfb86..1395b24 100644
--- a/tests/test_expressions.py
+++ b/tests/test_expressions.py
@@ -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""",
)