summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_databricks.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-05 18:41:08 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-05 18:41:08 +0000
commitba1aee6c083034bff5350be94acca6706d437491 (patch)
tree63bd1b1080121002fea92c6007583016c9e83b45 /tests/dialects/test_databricks.py
parentAdding upstream version 9.0.3. (diff)
downloadsqlglot-ba1aee6c083034bff5350be94acca6706d437491.tar.xz
sqlglot-ba1aee6c083034bff5350be94acca6706d437491.zip
Adding upstream version 9.0.6.upstream/9.0.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_databricks.py')
-rw-r--r--tests/dialects/test_databricks.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/dialects/test_databricks.py b/tests/dialects/test_databricks.py
new file mode 100644
index 0000000..e242e73
--- /dev/null
+++ b/tests/dialects/test_databricks.py
@@ -0,0 +1,33 @@
+from tests.dialects.test_dialect import Validator
+
+
+class TestDatabricks(Validator):
+ dialect = "databricks"
+
+ def test_datediff(self):
+ self.validate_all(
+ "SELECT DATEDIFF(year, 'start', 'end')",
+ write={
+ "tsql": "SELECT DATEDIFF(year, 'start', 'end')",
+ "databricks": "SELECT DATEDIFF(year, 'start', 'end')",
+ },
+ )
+
+ def test_add_date(self):
+ self.validate_all(
+ "SELECT DATEADD(year, 1, '2020-01-01')",
+ write={
+ "tsql": "SELECT DATEADD(year, 1, '2020-01-01')",
+ "databricks": "SELECT DATEADD(year, 1, '2020-01-01')",
+ },
+ )
+ self.validate_all(
+ "SELECT DATEDIFF('end', 'start')", write={"databricks": "SELECT DATEDIFF(DAY, 'start', 'end')"}
+ )
+ self.validate_all(
+ "SELECT DATE_ADD('2020-01-01', 1)",
+ write={
+ "tsql": "SELECT DATEADD(DAY, 1, '2020-01-01')",
+ "databricks": "SELECT DATEADD(DAY, 1, '2020-01-01')",
+ },
+ )