summaryrefslogtreecommitdiffstats
path: root/tests/test_parser.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-07-06 07:28:12 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-07-06 07:28:12 +0000
commit374a0f6318bcf423b1b784d30b25a8327c65cb24 (patch)
tree9303a1cbdba85b5d9781ebef32eb1902d3790c99 /tests/test_parser.py
parentReleasing debian version 16.7.7-1. (diff)
downloadsqlglot-374a0f6318bcf423b1b784d30b25a8327c65cb24.tar.xz
sqlglot-374a0f6318bcf423b1b784d30b25a8327c65cb24.zip
Merging upstream version 17.2.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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"