summaryrefslogtreecommitdiffstats
path: root/tests/test_parser.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-02-08 05:38:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-02-08 05:38:39 +0000
commitaedf35026379f52d7e2b4c1f957691410a758089 (patch)
tree86540364259b66741173d2333387b78d6f9c31e2 /tests/test_parser.py
parentAdding upstream version 20.11.0. (diff)
downloadsqlglot-aedf35026379f52d7e2b4c1f957691410a758089.tar.xz
sqlglot-aedf35026379f52d7e2b4c1f957691410a758089.zip
Adding upstream version 21.0.1.upstream/21.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_parser.py')
-rw-r--r--tests/test_parser.py36
1 files changed, 35 insertions, 1 deletions
diff --git a/tests/test_parser.py b/tests/test_parser.py
index 91fd4c6..c7e1dbe 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -10,7 +10,7 @@ from tests.helpers import assert_logger_contains
class TestParser(unittest.TestCase):
def test_parse_empty(self):
- with self.assertRaises(ParseError) as ctx:
+ with self.assertRaises(ParseError):
parse_one("")
def test_parse_into(self):
@@ -805,3 +805,37 @@ class TestParser(unittest.TestCase):
error_level=ErrorLevel.IGNORE,
)
self.assertEqual(ast[0].sql(), "CONCAT_WS()")
+
+ def test_parse_drop_schema(self):
+ for dialect in [None, "bigquery", "snowflake"]:
+ with self.subTest(dialect):
+ ast = parse_one("DROP SCHEMA catalog.schema", dialect=dialect)
+ self.assertEqual(
+ ast,
+ exp.Drop(
+ this=exp.Table(
+ this=None,
+ db=exp.Identifier(this="schema", quoted=False),
+ catalog=exp.Identifier(this="catalog", quoted=False),
+ ),
+ kind="SCHEMA",
+ ),
+ )
+ self.assertEqual(ast.sql(dialect=dialect), "DROP SCHEMA catalog.schema")
+
+ def test_parse_create_schema(self):
+ for dialect in [None, "bigquery", "snowflake"]:
+ with self.subTest(dialect):
+ ast = parse_one("CREATE SCHEMA catalog.schema", dialect=dialect)
+ self.assertEqual(
+ ast,
+ exp.Create(
+ this=exp.Table(
+ this=None,
+ db=exp.Identifier(this="schema", quoted=False),
+ catalog=exp.Identifier(this="catalog", quoted=False),
+ ),
+ kind="SCHEMA",
+ ),
+ )
+ self.assertEqual(ast.sql(dialect=dialect), "CREATE SCHEMA catalog.schema")