Skip to content

Commit

Permalink
Fix(bigquery): allow overlaps to be used as an identifier (#2273)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgesittas authored Sep 20, 2023
1 parent ccff88c commit ed8714f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sqlglot/dialects/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ class Parser(parser.Parser):
"OPTIONS": lambda self: exp.Properties(expressions=self._parse_with_property()),
}

RANGE_PARSERS = parser.Parser.RANGE_PARSERS.copy()
RANGE_PARSERS.pop(TokenType.OVERLAPS, None)

NULL_TOKENS = {TokenType.NULL, TokenType.UNKNOWN}

def _parse_table_part(self, schema: bool = False) -> t.Optional[exp.Expression]:
Expand Down
1 change: 1 addition & 0 deletions sqlglot/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ class Parser(metaclass=_Parser):
TokenType.NEXT,
TokenType.OFFSET,
TokenType.ORDINALITY,
TokenType.OVERLAPS,
TokenType.OVERWRITE,
TokenType.PARTITION,
TokenType.PERCENT,
Expand Down
4 changes: 4 additions & 0 deletions tests/dialects/test_bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ def test_bigquery(self):
self.validate_identity(
"SELECT LAST_VALUE(a IGNORE NULLS) OVER y FROM x WINDOW y AS (PARTITION BY CATEGORY)",
)
self.validate_identity(
"SELECT a overlaps",
"SELECT a AS overlaps",
)
self.validate_identity(
"SELECT y + 1 z FROM x GROUP BY y + 1 ORDER BY z",
"SELECT y + 1 AS z FROM x GROUP BY z ORDER BY z",
Expand Down

0 comments on commit ed8714f

Please sign in to comment.