summaryrefslogtreecommitdiffstats
path: root/tests/dataframe/unit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dataframe/unit')
-rw-r--r--tests/dataframe/unit/test_dataframe_writer.py7
-rw-r--r--tests/dataframe/unit/test_functions.py13
2 files changed, 15 insertions, 5 deletions
diff --git a/tests/dataframe/unit/test_dataframe_writer.py b/tests/dataframe/unit/test_dataframe_writer.py
index 042b915..3f45468 100644
--- a/tests/dataframe/unit/test_dataframe_writer.py
+++ b/tests/dataframe/unit/test_dataframe_writer.py
@@ -86,3 +86,10 @@ class TestDataFrameWriter(DataFrameSQLValidator):
"CREATE TABLE table_name AS SELECT `t12441`.`employee_id` AS `employee_id`, `t12441`.`fname` AS `fname`, `t12441`.`lname` AS `lname`, `t12441`.`age` AS `age`, `t12441`.`store_id` AS `store_id` FROM `t12441` AS `t12441`",
]
self.compare_sql(df, expected_statements)
+
+ def test_quotes(self):
+ sqlglot.schema.add_table('"Test"', {'"ID"': "STRING"})
+ df = self.spark.table('"Test"')
+ self.compare_sql(
+ df.select(df['"ID"']), ["SELECT `Test`.`ID` AS `ID` FROM `Test` AS `Test`"]
+ )
diff --git a/tests/dataframe/unit/test_functions.py b/tests/dataframe/unit/test_functions.py
index d9a32c4..befa68b 100644
--- a/tests/dataframe/unit/test_functions.py
+++ b/tests/dataframe/unit/test_functions.py
@@ -807,14 +807,17 @@ class TestFunctions(unittest.TestCase):
self.assertEqual("DATE_ADD(cola, 2)", col.sql())
col_col_for_add = SF.date_add("cola", "colb")
self.assertEqual("DATE_ADD(cola, colb)", col_col_for_add.sql())
+ current_date_add = SF.date_add(SF.current_date(), 5)
+ self.assertEqual("DATE_ADD(CURRENT_DATE, 5)", current_date_add.sql())
+ self.assertEqual("DATEADD(day, 5, CURRENT_DATE)", current_date_add.sql(dialect="snowflake"))
def test_date_sub(self):
col_str = SF.date_sub("cola", 2)
- self.assertEqual("DATE_SUB(cola, 2)", col_str.sql())
+ self.assertEqual("DATE_ADD(cola, -2)", col_str.sql())
col = SF.date_sub(SF.col("cola"), 2)
- self.assertEqual("DATE_SUB(cola, 2)", col.sql())
+ self.assertEqual("DATE_ADD(cola, -2)", col.sql())
col_col_for_add = SF.date_sub("cola", "colb")
- self.assertEqual("DATE_SUB(cola, colb)", col_col_for_add.sql())
+ self.assertEqual("DATE_ADD(cola, colb * -1)", col_col_for_add.sql())
def test_date_diff(self):
col_str = SF.date_diff("cola", "colb")
@@ -957,9 +960,9 @@ class TestFunctions(unittest.TestCase):
def test_sha1(self):
col_str = SF.sha1("Spark")
- self.assertEqual("SHA1('Spark')", col_str.sql())
+ self.assertEqual("SHA('Spark')", col_str.sql())
col = SF.sha1(SF.col("cola"))
- self.assertEqual("SHA1(cola)", col.sql())
+ self.assertEqual("SHA(cola)", col.sql())
def test_sha2(self):
col_str = SF.sha2("Spark", 256)