Repository: tobymao/sqlglot

Issue:
Fields with a name of some types (like number) are parsed incorrectly on Snowflake dialect
**Fully reproducible code snippet**
```
query = """
select
  id,
  int,
  number
from some.table
"""
sqlglot.parse(query, sqlglot.Dialects.SNOWFLAKE)
```

The `number` field is parsed as `DataType` instead of `Column`.
This was introduced on #3472 , as the new code replace it even if it is used as a name (and not a type)
It affects all names that match `DECIMAL` type on snowflake



Discussion:

Patch:
diff --git a/sqlglot/parser.py b/sqlglot/parser.py
index 3f3df800..6e5bd942 100644
--- a/sqlglot/parser.py
+++ b/sqlglot/parser.py
@@ -4199,7 +4199,20 @@ class Parser(metaclass=_Parser):
 
                 return self.expression(exp.Cast, this=this, to=data_type)
 
-            if data_type.expressions:
+            # The expressions arg gets set by the parser when we have something like DECIMAL(38, 0)
+            # in the input SQL. In that case, we'll produce these tokens: DECIMAL ( 38 , 0 )
+            #
+            # If the index difference here is greater than 1, that means the parser itself must have
+            # consumed additional tokens such as the DECIMAL scale and precision in the above example.
+            #
+            # If it's not greater than 1, then it must be 1, because we've consumed at least the type
+            # keyword, meaning that the expressions arg of the DataType must have gotten set by a
+            # callable in the TYPE_CONVERTERS mapping. For example, Snowflake converts DECIMAL to
+            # DECIMAL(38, 0)) in order to facilitate the data type's transpilation.
+            #
+            # In these cases, we don't really want to return the converted type, but instead retreat
+            # and try to parse a Column or Identifier in the section below.
+            if data_type.expressions and self._index - index > 1:
                 self._retreat(index2)
                 return self._parse_column_ops(data_type)
 


Test patch:
diff --git a/tests/dialects/test_snowflake.py b/tests/dialects/test_snowflake.py
index 84b4aa8b..b57cfda8 100644
--- a/tests/dialects/test_snowflake.py
+++ b/tests/dialects/test_snowflake.py
@@ -48,6 +48,7 @@ WHERE
   )""",
         )
 
+        self.validate_identity("SELECT number").selects[0].assert_is(exp.Column)
         self.validate_identity("INTERVAL '4 years, 5 months, 3 hours'")
         self.validate_identity("ALTER TABLE table1 CLUSTER BY (name DESC)")
         self.validate_identity("SELECT rename, replace")