Repository: tobymao/sqlglot

Issue:
`DATETIME64` parameters are parsed as `DataTypeSize` expressions
**Before you file an issue**
When I parse a clickhouse typestring `DateTime64(1, 'Europe/Berlin')` into a datatype expression, both the `scale` and `timezone` parameters are parsed as `DataTypeSize` expressions. I'd expect them to be `Literal.number(...)` and `Literal.string(...)` respectively. This probably applies to the other timestamp-like datatypes as well.

**Fully reproducible code snippet**

```py
In [1]: import sqlglot.expressions as sge

In [2]: import sqlglot as sg

In [3]: typ = sg.parse_one("DateTime64(1, 'Europe/Berlin')", into=sge.DataType, read="clickhouse")

In [4]: typ
Out[4]:
(DATATYPE this: Type.DATETIME64, expressions:
  (DATATYPESIZE this:
    (LITERAL this: 1, is_string: False)),
  (DATATYPESIZE this:
    (LITERAL this: Europe/Berlin, is_string: True)), nested: False, prefix: False)
```



Discussion:

Patch:
diff --git a/sqlglot/dialects/hive.py b/sqlglot/dialects/hive.py
index 69c92225..566373ec 100644
--- a/sqlglot/dialects/hive.py
+++ b/sqlglot/dialects/hive.py
@@ -480,7 +480,7 @@ class Hive(Dialect):
             elif expression.this in exp.DataType.TEMPORAL_TYPES:
                 expression = exp.DataType.build(expression.this)
             elif expression.is_type("float"):
-                size_expression = expression.find(exp.DataTypeSize)
+                size_expression = expression.find(exp.DataTypeParam)
                 if size_expression:
                     size = int(size_expression.name)
                     expression = (
diff --git a/sqlglot/expressions.py b/sqlglot/expressions.py
index 9672b8e0..b34e833d 100644
--- a/sqlglot/expressions.py
+++ b/sqlglot/expressions.py
@@ -3392,7 +3392,7 @@ class Boolean(Condition):
     pass
 
 
-class DataTypeSize(Expression):
+class DataTypeParam(Expression):
     arg_types = {"this": True, "expression": False}
 
 
diff --git a/sqlglot/generator.py b/sqlglot/generator.py
index ac0fc706..7fa75046 100644
--- a/sqlglot/generator.py
+++ b/sqlglot/generator.py
@@ -833,7 +833,7 @@ class Generator:
         string = self.escape_str(expression.this.replace("\\", "\\\\"))
         return f"{self.QUOTE_START}{string}{self.QUOTE_END}"
 
-    def datatypesize_sql(self, expression: exp.DataTypeSize) -> str:
+    def datatypeparam_sql(self, expression: exp.DataTypeParam) -> str:
         this = self.sql(expression, "this")
         specifier = self.sql(expression, "expression")
         specifier = f" {specifier}" if specifier else ""
diff --git a/sqlglot/parser.py b/sqlglot/parser.py
index 14c5e964..ba0bc770 100644
--- a/sqlglot/parser.py
+++ b/sqlglot/parser.py
@@ -3111,13 +3111,13 @@ class Parser(metaclass=_Parser):
 
         return this
 
-    def _parse_type_size(self) -> t.Optional[exp.DataTypeSize]:
+    def _parse_type_size(self) -> t.Optional[exp.DataTypeParam]:
         this = self._parse_type()
         if not this:
             return None
 
         return self.expression(
-            exp.DataTypeSize, this=this, expression=self._parse_var(any_token=True)
+            exp.DataTypeParam, this=this, expression=self._parse_var(any_token=True)
         )
 
     def _parse_types(
diff --git a/sqlglot/transforms.py b/sqlglot/transforms.py
index 7c7c2a7d..dc7a8d24 100644
--- a/sqlglot/transforms.py
+++ b/sqlglot/transforms.py
@@ -126,7 +126,7 @@ def remove_precision_parameterized_types(expression: exp.Expression) -> exp.Expr
     """
     for node in expression.find_all(exp.DataType):
         node.set(
-            "expressions", [e for e in node.expressions if not isinstance(e, exp.DataTypeSize)]
+            "expressions", [e for e in node.expressions if not isinstance(e, exp.DataTypeParam)]
         )
 
     return expression


Test patch:
diff --git a/tests/test_parser.py b/tests/test_parser.py
index 2c0b76fb..a853a757 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -438,7 +438,7 @@ class TestParser(unittest.TestCase):
         self.assertIsInstance(parse_one("TIMESTAMP('2022-01-01')"), exp.Func)
         self.assertIsInstance(parse_one("TIMESTAMP()"), exp.Func)
         self.assertIsInstance(parse_one("map.x"), exp.Column)
-        self.assertIsInstance(parse_one("CAST(x AS CHAR(5))").to.expressions[0], exp.DataTypeSize)
+        self.assertIsInstance(parse_one("CAST(x AS CHAR(5))").to.expressions[0], exp.DataTypeParam)
         self.assertEqual(parse_one("1::int64", dialect="bigquery"), parse_one("CAST(1 AS BIGINT)"))
 
     def test_set_expression(self):