diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-07-06 07:28:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-07-06 07:28:09 +0000 |
commit | 52f4a5e2260f3e5b919b4e270339afd670bf0b8a (patch) | |
tree | 5ca419af0e2e409018492b82f5b9847f0112b5fb /tests/test_parser.py | |
parent | Adding upstream version 16.7.7. (diff) | |
download | sqlglot-52f4a5e2260f3e5b919b4e270339afd670bf0b8a.tar.xz sqlglot-52f4a5e2260f3e5b919b4e270339afd670bf0b8a.zip |
Adding upstream version 17.2.0.upstream/17.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/test_parser.py | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/tests/test_parser.py b/tests/test_parser.py index 96192cd..2fa6a09 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -1,3 +1,4 @@ +import time import unittest from unittest.mock import patch @@ -67,7 +68,7 @@ class TestParser(unittest.TestCase): }, ] with self.assertRaises(ParseError) as ctx: - parse_one("SELECT 1;", "sqlite", [exp.From, exp.Join]) + parse_one("SELECT 1;", "sqlite", into=[exp.From, exp.Join]) self.assertEqual(str(ctx.exception), expected_message) self.assertEqual(ctx.exception.errors, expected_errors) @@ -318,6 +319,7 @@ class TestParser(unittest.TestCase): self.assertIsInstance(parse_one("TIMESTAMP()"), exp.Func) self.assertIsInstance(parse_one("map.x"), exp.Column) self.assertIsInstance(parse_one("CAST(x AS CHAR(5))").to.expressions[0], exp.DataTypeSize) + self.assertEqual(parse_one("1::int64", dialect="bigquery"), parse_one("CAST(1 AS BIGINT)")) def test_set_expression(self): set_ = parse_one("SET") @@ -522,6 +524,55 @@ class TestParser(unittest.TestCase): columns = expr.args["from"].this.args["pivots"][0].args["columns"] self.assertEqual(expected_columns, [col.sql(dialect=dialect) for col in columns]) + def test_parse_nested(self): + now = time.time() + query = parse_one( + """ + select * + FROM a + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + LEFT JOIN b ON a.id = b.id + """ + ) + self.assertIsNotNone(query) + self.assertLessEqual(time.time() - now, 0.1) + def test_parse_properties(self): self.assertEqual( parse_one("create materialized table x").sql(), "CREATE MATERIALIZED TABLE x" |