Repository: tobymao/sqlglot

Issue:
Parser fails when using "interval" as name for a struct field 
This is a snippet that reproduces the problem:

```python
import sqlglot

working_sql = """
CREATE TABLE my_table (
  col STRUCT<`interval`: DOUBLE COMMENT 'aaa'>
)
"""

broken_sql = """
CREATE TABLE my_table (
  col STRUCT<interval: DOUBLE COMMENT 'aaa'>
)
"""

sqlglot.parse_one(working_sql, read="databricks")
print("If 'interval' is surrounded by backticks it works")

print("But if it is not then it breaks:")
sqlglot.parse_one(broken_sql, read="databricks")
```

As far as I can see (please correct me if I'm wrong), **even without backticks the parser should work**. Relevant links:
- https://docs.databricks.com/en/sql/language-manual/data-types/struct-type.html
- https://docs.databricks.com/en/sql/language-manual/sql-ref-identifiers.html
- https://docs.databricks.com/en/sql/language-manual/sql-ref-ansi-compliance.html#sql-keywords -> even if `spark.sql.ansi.enabled` is true, `interval` is not a reserved keyword

Thanks!



Discussion:

Resolving patch:
diff --git a/sqlglot/dialects/mysql.py b/sqlglot/dialects/mysql.py
--- a/sqlglot/dialects/mysql.py
+++ b/sqlglot/dialects/mysql.py
@@ -520,7 +520,7 @@ def _parse_set_item_names(self) -> exp.Expression:
 
             return self.expression(exp.SetItem, this=charset, collate=collate, kind="NAMES")
 
-        def _parse_type(self) -> t.Optional[exp.Expression]:
+        def _parse_type(self, parse_interval: bool = True) -> t.Optional[exp.Expression]:
             # mysql binary is special and can work anywhere, even in order by operations
             # it operates like a no paren func
             if self._match(TokenType.BINARY, advance=False):
@@ -529,7 +529,7 @@ def _parse_type(self) -> t.Optional[exp.Expression]:
                 if isinstance(data_type, exp.DataType):
                     return self.expression(exp.Cast, this=self._parse_column(), to=data_type)
 
-            return super()._parse_type()
+            return super()._parse_type(parse_interval=parse_interval)
 
     class Generator(generator.Generator):
         LOCKING_READS_SUPPORTED = True
diff --git a/sqlglot/parser.py b/sqlglot/parser.py
--- a/sqlglot/parser.py
+++ b/sqlglot/parser.py
@@ -3249,8 +3249,8 @@ def _parse_unary(self) -> t.Optional[exp.Expression]:
             return self.UNARY_PARSERS[self._prev.token_type](self)
         return self._parse_at_time_zone(self._parse_type())
 
-    def _parse_type(self) -> t.Optional[exp.Expression]:
-        interval = self._parse_interval()
+    def _parse_type(self, parse_interval: bool = True) -> t.Optional[exp.Expression]:
+        interval = parse_interval and self._parse_interval()
         if interval:
             return interval
 
@@ -3426,7 +3426,7 @@ def _parse_types(
         return this
 
     def _parse_struct_types(self) -> t.Optional[exp.Expression]:
-        this = self._parse_type() or self._parse_id_var()
+        this = self._parse_type(parse_interval=False) or self._parse_id_var()
         self._match(TokenType.COLON)
         return self._parse_column_def(this)
 


Test patch:
diff --git a/tests/dialects/test_databricks.py b/tests/dialects/test_databricks.py
--- a/tests/dialects/test_databricks.py
+++ b/tests/dialects/test_databricks.py
@@ -5,6 +5,7 @@ class TestDatabricks(Validator):
     dialect = "databricks"
 
     def test_databricks(self):
+        self.validate_identity("CREATE TABLE t (c STRUCT<interval: DOUBLE COMMENT 'aaa'>)")
         self.validate_identity("SELECT CAST('11 23:4:0' AS INTERVAL DAY TO HOUR)")
         self.validate_identity("SELECT CAST('11 23:4:0' AS INTERVAL DAY TO MINUTE)")
         self.validate_identity("SELECT CAST('11 23:4:0' AS INTERVAL DAY TO SECOND)")