Repository: tobymao/sqlglot

Issue:
[Databricks] Date units in functions interpreted as columns
First off, great module! 

I've started using sqlglot somewhat recently and ran into what I think may be a bug:

```
import sqlglot
from sqlglot import parse_one, exp
from sqlglot.optimizer.qualify import qualify

sql = "select date_diff(day, created_at, current_date()) from test"
schema = {"test": {"created_at": "timestamp"}}
ast = parse_one(sql, dialect="databricks")
qualify(ast, schema=schema, dialect="databricks")
```
`sqlglot.errors.OptimizeError: Column '"day"' could not be resolved`

The [examples](https://docs.gcp.databricks.com/en/sql/language-manual/functions/date_diff.html#examples) in the Databricks docs show an unquoted date unit. I assume that other Databricks date/time functions that accept units may experience the same issue. 

Discussion:

Patch:
diff --git a/sqlglot/dialects/databricks.py b/sqlglot/dialects/databricks.py
index fc1772d5..e2628dc9 100644
--- a/sqlglot/dialects/databricks.py
+++ b/sqlglot/dialects/databricks.py
@@ -50,6 +50,7 @@ class Databricks(Spark):
             "DATEADD": build_date_delta(exp.DateAdd),
             "DATE_ADD": build_date_delta(exp.DateAdd),
             "DATEDIFF": build_date_delta(exp.DateDiff),
+            "DATE_DIFF": build_date_delta(exp.DateDiff),
             "TIMESTAMPDIFF": build_date_delta(exp.TimestampDiff),
             "GET_JSON_OBJECT": _build_json_extract,
         }
diff --git a/sqlglot/dialects/spark.py b/sqlglot/dialects/spark.py
index b71204b8..2f2ec878 100644
--- a/sqlglot/dialects/spark.py
+++ b/sqlglot/dialects/spark.py
@@ -33,7 +33,7 @@ def _build_datediff(args: t.List) -> exp.Expression:
     expression = seq_get(args, 1)
 
     if len(args) == 3:
-        unit = this
+        unit = exp.var(t.cast(exp.Expression, this).name)
         this = args[2]
 
     return exp.DateDiff(
@@ -107,6 +107,7 @@ class Spark(Spark2):
             "DATEADD": _build_dateadd,
             "TIMESTAMPADD": _build_dateadd,
             "DATEDIFF": _build_datediff,
+            "DATE_DIFF": _build_datediff,
             "TIMESTAMP_LTZ": _build_as_cast("TIMESTAMP_LTZ"),
             "TIMESTAMP_NTZ": _build_as_cast("TIMESTAMP_NTZ"),
             "TRY_ELEMENT_AT": lambda args: exp.Bracket(


Test patch:
diff --git a/tests/dialects/test_databricks.py b/tests/dialects/test_databricks.py
index 785ea922..471830ff 100644
--- a/tests/dialects/test_databricks.py
+++ b/tests/dialects/test_databricks.py
@@ -1,4 +1,4 @@
-from sqlglot import transpile
+from sqlglot import exp, transpile
 from sqlglot.errors import ParseError
 from tests.dialects.test_dialect import Validator
 
@@ -50,6 +50,10 @@ class TestDatabricks(Validator):
         self.validate_identity(
             "COPY INTO target FROM `s3://link` FILEFORMAT = AVRO VALIDATE = ALL FILES = ('file1', 'file2') FORMAT_OPTIONS ('opt1'='true', 'opt2'='test') COPY_OPTIONS ('mergeSchema'='true')"
         )
+        self.validate_identity(
+            "DATE_DIFF(day, created_at, current_date())",
+            "DATEDIFF(DAY, created_at, CURRENT_DATE)",
+        ).args["unit"].assert_is(exp.Var)
         self.validate_identity(
             r'SELECT r"\\foo.bar\"',
             r"SELECT '\\\\foo.bar\\'",