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.py35
1 files changed, 34 insertions, 1 deletions
diff --git a/tests/test_parser.py b/tests/test_parser.py
index 6bcdb64..2cefc07 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -503,7 +503,7 @@ class TestParser(unittest.TestCase):
self.assertIsInstance(set_item, exp.SetItem)
self.assertIsInstance(set_item.this, exp.EQ)
- self.assertIsInstance(set_item.this.this, exp.Identifier)
+ self.assertIsInstance(set_item.this.this, exp.Column)
self.assertIsInstance(set_item.this.expression, exp.Literal)
self.assertEqual(set_item.args.get("kind"), "SESSION")
@@ -856,5 +856,38 @@ class TestParser(unittest.TestCase):
with self.subTest(dialect):
self.assertEqual(parse_one(sql, dialect=dialect).sql(dialect=dialect), sql)
+ def test_alter_set(self):
+ sqls = [
+ "ALTER TABLE tbl SET TBLPROPERTIES ('x'='1', 'Z'='2')",
+ "ALTER TABLE tbl SET SERDE 'test' WITH SERDEPROPERTIES ('k'='v', 'kay'='vee')",
+ "ALTER TABLE tbl SET SERDEPROPERTIES ('k'='v', 'kay'='vee')",
+ "ALTER TABLE tbl SET LOCATION 'new_location'",
+ "ALTER TABLE tbl SET FILEFORMAT file_format",
+ "ALTER TABLE tbl SET TAGS ('tag1' = 't1', 'tag2' = 't2')",
+ ]
+
+ for dialect in (
+ "hive",
+ "spark2",
+ "spark",
+ "databricks",
+ ):
+ for sql in sqls:
+ with self.subTest(f"Testing query '{sql}' for dialect {dialect}"):
+ self.assertEqual(parse_one(sql, dialect=dialect).sql(dialect=dialect), sql)
+
def test_distinct_from(self):
self.assertIsInstance(parse_one("a IS DISTINCT FROM b OR c IS DISTINCT FROM d"), exp.Or)
+
+ def test_trailing_comments(self):
+ expressions = parse("""
+ select * from x;
+ -- my comment
+ """)
+
+ self.assertEqual(
+ ";\n".join(e.sql() for e in expressions), "SELECT * FROM x;\n/* my comment */"
+ )
+
+ def test_parse_prop_eq(self):
+ self.assertIsInstance(parse_one("x(a := b and c)").expressions[0], exp.PropertyEQ)