diff options
Diffstat (limited to 'tests/test_expressions.py')
-rw-r--r-- | tests/test_expressions.py | 19 |
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""", ) |