summaryrefslogtreecommitdiffstats
path: root/tests/test_parser.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 05:35:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 05:35:50 +0000
commit8f1b330983bddb35e2ec61a5667a84318bad88ef (patch)
tree32b74e964839c34014d31ec828fc6521323b9edc /tests/test_parser.py
parentAdding upstream version 23.13.7. (diff)
downloadsqlglot-upstream/23.16.0.tar.xz
sqlglot-upstream/23.16.0.zip
Adding upstream version 23.16.0.upstream/23.16.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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)