Repository: tobymao/sqlglot

Issue:
Snowflake dialect fails to parse expression when casting object constant to variant using double colon syntax
As noted in the [object-constants](https://docs.snowflake.com/en/sql-reference/data-types-semistructured#object-constants) docs, using ` { 'test': 'test' } ` is valid SQL. 

Its also possible to cast an object constant to a variant using `SELECT to_variant({'test': 'best'});` 

Therefore when attempting to cast it as follows `{ 'test': 'test' }::variant`, I'd expect success. However, it fails 

```python
sql = """SELECT {'test': 'best'}::variant"""

import sqlglot

sqlglot.parse_one(sql, read="snowflake")
```

```
Traceback (most recent call last):
  File "/Users/wesley.hamburger/Library/Application Support/Code/User/globalStorage/buenon.scratchpads/scratchpads/1a4f2b73c916c9af3926773a674c6453/scratch31.py", line 5, in <module>
    sqlglot.parse_one(sql, read="snowflake")
  File "/Users/wesley.hamburger/.pyenv/versions/3.10.11/envs/snowflake-pipe/lib/python3.10/site-packages/sqlglot/__init__.py", line 125, in parse_one
    result = dialect.parse(sql, **opts)
  File "/Users/wesley.hamburger/.pyenv/versions/3.10.11/envs/snowflake-pipe/lib/python3.10/site-packages/sqlglot/dialects/dialect.py", line 285, in parse
    return self.parser(**opts).parse(self.tokenize(sql), sql)
  File "/Users/wesley.hamburger/.pyenv/versions/3.10.11/envs/snowflake-pipe/lib/python3.10/site-packages/sqlglot/parser.py", line 882, in parse
    return self._parse(
  File "/Users/wesley.hamburger/.pyenv/versions/3.10.11/envs/snowflake-pipe/lib/python3.10/site-packages/sqlglot/parser.py", line 951, in _parse
    self.raise_error("Invalid expression / Unexpected token")
  File "/Users/wesley.hamburger/.pyenv/versions/3.10.11/envs/snowflake-pipe/lib/python3.10/site-packages/sqlglot/parser.py", line 992, in raise_error
    raise error
sqlglot.errors.ParseError: Invalid expression / Unexpected token. Line 1, Col: 25.
  SELECT {'test': 'best'}::variant
```

Discussion:

Patch:
diff --git a/sqlglot/parser.py b/sqlglot/parser.py
index 6bb7de99..ca8f6efe 100644
--- a/sqlglot/parser.py
+++ b/sqlglot/parser.py
@@ -3251,7 +3251,7 @@ class Parser(metaclass=_Parser):
                 return self._parse_column()
             return self._parse_column_ops(data_type)
 
-        return this
+        return this and self._parse_column_ops(this)
 
     def _parse_type_size(self) -> t.Optional[exp.DataTypeParam]:
         this = self._parse_type()


Test patch:
diff --git a/tests/dialects/test_snowflake.py b/tests/dialects/test_snowflake.py
index 93bfe281..4f80c5cf 100644
--- a/tests/dialects/test_snowflake.py
+++ b/tests/dialects/test_snowflake.py
@@ -78,6 +78,10 @@ class TestSnowflake(Validator):
             r"SELECT $$a ' \ \t \x21 z $ $$",
             r"SELECT 'a \' \\ \\t \\x21 z $ '",
         )
+        self.validate_identity(
+            "SELECT {'test': 'best'}::VARIANT",
+            "SELECT CAST(OBJECT_CONSTRUCT('test', 'best') AS VARIANT)",
+        )
 
         self.validate_all("CAST(x AS BYTEINT)", write={"snowflake": "CAST(x AS INT)"})
         self.validate_all("CAST(x AS CHAR VARYING)", write={"snowflake": "CAST(x AS VARCHAR)"})