Repository: tobymao/sqlglot

Issue:
ParseError in Databricks dialect with '::type' casting and timestamp literals
**Before you file an issue**
 I am using the correct `read` dialect: `read="databricks"`
I am using  

<!-- Failed to upload "sqlglot.jpg" -->

<!-- Failed to upload "sqlglot 2.jpg" -->

### Problem

When parsing SQL written for Databricks (or Spark-like environments), `sqlglot` fails with a `ParseError` if the query includes:

1. style casting (e.g., `'...'::date`)
2. Timestamp literals using dotted time formats like `'2025-04-29 18.47.18'`



**Fully reproducible code snippet**
from sqlglot import parse_one

query = """
SELECT
    r.id,
    convert_timezone(
        'america/sao_paulo',
        'utc',
        timestamp '2025-04-29 18.47.18'::date
    ) AS converted_date,
    r.created_at
FROM receivables r
WHERE r.created_at < timestamp '2025-04-30 00.00.00'

"""

try:
    parsed = parse_one(query, dialect='databricks')
    print(parsed.sql(dialect='databricks')) 
except Exception as e:
    print("Erro no parse:", e)


**Official Documentation**
Please include links to official SQL documentation related to your issue.

Discussion:

Solution patch:
diff --git a/sqlglot/parser.py b/sqlglot/parser.py
index 85d3cd8ff7..e5c7da7062 100644
--- a/sqlglot/parser.py
+++ b/sqlglot/parser.py
@@ -5041,6 +5041,8 @@ def _parse_type(
             this = self._parse_primary()
 
             if isinstance(this, exp.Literal):
+                this = self._parse_column_ops(this)
+
                 parser = self.TYPE_LITERAL_PARSERS.get(data_type.this)
                 if parser:
                     return parser(self, this, data_type)


Test patch:
diff --git a/tests/dialects/test_databricks.py b/tests/dialects/test_databricks.py
index 982c7bc6bc..1e94d50fa7 100644
--- a/tests/dialects/test_databricks.py
+++ b/tests/dialects/test_databricks.py
@@ -35,6 +35,7 @@ def test_databricks(self):
         self.validate_identity("SELECT ${x} FROM ${y} WHERE ${z} > 1")
         self.validate_identity("CREATE TABLE foo (x DATE GENERATED ALWAYS AS (CAST(y AS DATE)))")
         self.validate_identity("TRUNCATE TABLE t1 PARTITION(age = 10, name = 'test', address)")
+        self.validate_identity("SELECT PARSE_JSON('{}')")
         self.validate_identity(
             "CREATE TABLE IF NOT EXISTS db.table (a TIMESTAMP, b BOOLEAN GENERATED ALWAYS AS (NOT a IS NULL)) USING DELTA"
         )
@@ -56,7 +57,10 @@ def test_databricks(self):
         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("SELECT PARSE_JSON('{}')")
+        self.validate_identity(
+            "SELECT TIMESTAMP '2025-04-29 18.47.18'::DATE",
+            "SELECT CAST(CAST('2025-04-29 18.47.18' AS DATE) AS TIMESTAMP)",
+        )
         self.validate_identity(
             "SELECT DATE_FORMAT(CAST(FROM_UTC_TIMESTAMP(foo, 'America/Los_Angeles') AS TIMESTAMP), 'yyyy-MM-dd HH:mm:ss') AS foo FROM t",
             "SELECT DATE_FORMAT(CAST(FROM_UTC_TIMESTAMP(CAST(foo AS TIMESTAMP), 'America/Los_Angeles') AS TIMESTAMP), 'yyyy-MM-dd HH:mm:ss') AS foo FROM t",