summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_spark.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 08:12:52 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 08:12:52 +0000
commita1f10f8d39404d9bae42a64efaf505fa12f34c1a (patch)
tree9eb894268f2a145aa9d42b1726a555ab1359810f /tests/dialects/test_spark.py
parentAdding upstream version 25.8.1. (diff)
downloadsqlglot-upstream/25.16.1.tar.xz
sqlglot-upstream/25.16.1.zip
Adding upstream version 25.16.1.upstream/25.16.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_spark.py')
-rw-r--r--tests/dialects/test_spark.py39
1 files changed, 37 insertions, 2 deletions
diff --git a/tests/dialects/test_spark.py b/tests/dialects/test_spark.py
index fc3146f..a2d87df 100644
--- a/tests/dialects/test_spark.py
+++ b/tests/dialects/test_spark.py
@@ -129,6 +129,16 @@ TBLPROPERTIES (
"spark": "ALTER TABLE StudentInfo DROP COLUMNS (LastName, DOB)",
},
)
+ self.validate_identity("ALTER VIEW StudentInfoView AS SELECT * FROM StudentInfo")
+ self.validate_identity("ALTER VIEW StudentInfoView AS SELECT LastName FROM StudentInfo")
+ self.validate_identity("ALTER VIEW StudentInfoView RENAME TO StudentInfoViewRenamed")
+ self.validate_identity(
+ "ALTER VIEW StudentInfoView SET TBLPROPERTIES ('key1'='val1', 'key2'='val2')"
+ )
+ self.validate_identity(
+ "ALTER VIEW StudentInfoView UNSET TBLPROPERTIES ('key1', 'key2')",
+ check_command_warning=True,
+ )
def test_to_date(self):
self.validate_all(
@@ -298,6 +308,13 @@ TBLPROPERTIES (
)
self.validate_all(
+ "SELECT DATE_FORMAT(DATE '2020-01-01', 'EEEE') AS weekday",
+ write={
+ "presto": "SELECT DATE_FORMAT(CAST(CAST('2020-01-01' AS DATE) AS TIMESTAMP), '%W') AS weekday",
+ "spark": "SELECT DATE_FORMAT(CAST(CAST('2020-01-01' AS DATE) AS TIMESTAMP), 'EEEE') AS weekday",
+ },
+ )
+ self.validate_all(
"SELECT TRY_ELEMENT_AT(MAP(1, 'a', 2, 'b'), 2)",
read={
"databricks": "SELECT TRY_ELEMENT_AT(MAP(1, 'a', 2, 'b'), 2)",
@@ -557,7 +574,10 @@ TBLPROPERTIES (
)
self.validate_all(
- "CAST(x AS TIMESTAMP)", read={"trino": "CAST(x AS TIMESTAMP(6) WITH TIME ZONE)"}
+ "CAST(x AS TIMESTAMP)",
+ read={
+ "trino": "CAST(x AS TIMESTAMP(6) WITH TIME ZONE)",
+ },
)
self.validate_all(
"SELECT DATE_ADD(my_date_column, 1)",
@@ -688,6 +708,7 @@ TBLPROPERTIES (
"trino": "SELECT DATE_ADD('MONTH', 20, col)",
},
)
+ self.validate_identity("DESCRIBE schema.test PARTITION(ds = '2024-01-01')")
def test_bool_or(self):
self.validate_all(
@@ -805,8 +826,22 @@ TBLPROPERTIES (
self.assertEqual(query.sql(name), without_modifiers)
def test_schema_binding_options(self):
- for schema_binding in ("BINDING", "COMPENSATION", "TYPE EVOLUTION", "EVOLUTION"):
+ for schema_binding in (
+ "BINDING",
+ "COMPENSATION",
+ "TYPE EVOLUTION",
+ "EVOLUTION",
+ ):
with self.subTest(f"Test roundtrip of VIEW schema binding {schema_binding}"):
self.validate_identity(
f"CREATE VIEW emp_v WITH SCHEMA {schema_binding} AS SELECT * FROM emp"
)
+
+ def test_minus(self):
+ self.validate_all(
+ "SELECT * FROM db.table1 MINUS SELECT * FROM db.table2",
+ write={
+ "spark": "SELECT * FROM db.table1 EXCEPT SELECT * FROM db.table2",
+ "databricks": "SELECT * FROM db.table1 EXCEPT SELECT * FROM db.table2",
+ },
+ )