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.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/test_parser.py b/tests/test_parser.py
index ae2e4cd..03b801b 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -8,7 +8,8 @@ from tests.helpers import assert_logger_contains
class TestParser(unittest.TestCase):
def test_parse_empty(self):
- self.assertIsNone(parse_one(""))
+ with self.assertRaises(ParseError) as ctx:
+ parse_one("")
def test_parse_into(self):
self.assertIsInstance(parse_one("left join foo", into=exp.Join), exp.Join)
@@ -90,6 +91,9 @@ class TestParser(unittest.TestCase):
parse_one("""SELECT * FROM x CROSS JOIN y, z LATERAL VIEW EXPLODE(y)""").sql(),
"""SELECT * FROM x, z CROSS JOIN y LATERAL VIEW EXPLODE(y)""",
)
+ self.assertIsNone(
+ parse_one("create table a as (select b from c) index").find(exp.TableAlias)
+ )
def test_command(self):
expressions = parse("SET x = 1; ADD JAR s3://a; SELECT 1", read="hive")
@@ -155,6 +159,11 @@ class TestParser(unittest.TestCase):
assert expressions[0].args["from"].expressions[0].this.name == "a"
assert expressions[1].args["from"].expressions[0].this.name == "b"
+ expressions = parse("SELECT 1; ; SELECT 2")
+
+ assert len(expressions) == 3
+ assert expressions[1] is None
+
def test_expression(self):
ignore = Parser(error_level=ErrorLevel.IGNORE)
self.assertIsInstance(ignore.expression(exp.Hint, expressions=[""]), exp.Hint)