diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-17 10:32:12 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-17 10:32:12 +0000 |
commit | 244a05de60c9417daab9528b51788c3d2a00dc5f (patch) | |
tree | 89a9c82aa41d397e1b81c320ad7a287b6c80f313 /tests/test_parser.py | |
parent | Adding upstream version 10.4.2. (diff) | |
download | sqlglot-244a05de60c9417daab9528b51788c3d2a00dc5f.tar.xz sqlglot-244a05de60c9417daab9528b51788c3d2a00dc5f.zip |
Adding upstream version 10.5.2.upstream/10.5.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_parser.py')
-rw-r--r-- | tests/test_parser.py | 11 |
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) |