Repository: tobymao/sqlglot

Issue:
[Postgres 14.4] Parser does not recognize interval type when using cast() function
Example (valid sql):

```
select cast('1 day' as interval)
```
Result:
```
ParseError: Expected TYPE after CAST. Line 1, Col: 24.
  select cast('1 day' as interval)
```

Discussion:

Patch:
diff --git a/sqlglot/expressions.py b/sqlglot/expressions.py
index 8752a118..12d5d721 100644
--- a/sqlglot/expressions.py
+++ b/sqlglot/expressions.py
@@ -1654,6 +1654,7 @@ class DataType(Expression):
         DECIMAL = auto()
         BOOLEAN = auto()
         JSON = auto()
+        INTERVAL = auto()
         TIMESTAMP = auto()
         TIMESTAMPTZ = auto()
         DATE = auto()
diff --git a/sqlglot/parser.py b/sqlglot/parser.py
index 508bed86..b886d62b 100644
--- a/sqlglot/parser.py
+++ b/sqlglot/parser.py
@@ -78,6 +78,7 @@ class Parser:
         TokenType.TEXT,
         TokenType.BINARY,
         TokenType.JSON,
+        TokenType.INTERVAL,
         TokenType.TIMESTAMP,
         TokenType.TIMESTAMPTZ,
         TokenType.DATETIME,


Test patch:
diff --git a/tests/dialects/test_dialect.py b/tests/dialects/test_dialect.py
index 39935659..9d7df238 100644
--- a/tests/dialects/test_dialect.py
+++ b/tests/dialects/test_dialect.py
@@ -164,6 +164,12 @@ class TestDialect(Validator):
                 "starrocks": "CAST(a AS DOUBLE)",
             },
         )
+        self.validate_all(
+            "CAST('1 DAY' AS INTERVAL)",
+            write={
+                "postgres": "CAST('1 DAY' AS INTERVAL)",
+            },
+        )
         self.validate_all(
             "CAST(a AS TIMESTAMP)", write={"starrocks": "CAST(a AS DATETIME)"}
         )