Repository: tobymao/sqlglot

Issue:
Parsing fails when struct / json field is called `select`
**Fully reproducible code snippet**
```
    query = """
select
    invocations.invocation_args:select::varchar as invocation_select
from table
"""
sqlglot.parse(query, sqlglot.Dialects.SNOWFLAKE)
```

This snippet raises an exception: `sqlglot.errors.ParseError: Invalid expression / Unexpected token. Line 3, Col: 19.`


Discussion:

Patch:
diff --git a/sqlglot/parser.py b/sqlglot/parser.py
index b99d34c0..854f5e7d 100644
--- a/sqlglot/parser.py
+++ b/sqlglot/parser.py
@@ -4534,7 +4534,11 @@ class Parser(metaclass=_Parser):
 
         while self._match(TokenType.COLON):
             start_index = self._index
-            path = self._parse_column_ops(self._parse_field(any_token=True))
+
+            # Snowflake allows reserved keywords as json keys but advance_any() excludes TokenType.SELECT from any_tokens=True
+            path = self._parse_column_ops(
+                self._parse_field(any_token=True, tokens=(TokenType.SELECT,))
+            )
 
             # The cast :: operator has a lower precedence than the extraction operator :, so
             # we rearrange the AST appropriately to avoid casting the JSON path


Test patch:
diff --git a/tests/dialects/test_snowflake.py b/tests/dialects/test_snowflake.py
index e5bf4f27..12864369 100644
--- a/tests/dialects/test_snowflake.py
+++ b/tests/dialects/test_snowflake.py
@@ -125,6 +125,10 @@ WHERE
             "SELECT a:from::STRING, a:from || ' test' ",
             "SELECT CAST(GET_PATH(a, 'from') AS TEXT), GET_PATH(a, 'from') || ' test'",
         )
+        self.validate_identity(
+            "SELECT a:select",
+            "SELECT GET_PATH(a, 'select')",
+        )
         self.validate_identity("x:from", "GET_PATH(x, 'from')")
         self.validate_identity(
             "value:values::string::int",