summaryrefslogtreecommitdiffstats
path: root/tests/test_parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_parser.py')
-rw-r--r--tests/test_parser.py53
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"