Skip to content

Commit 2b4e3fd

Browse files
committed
first arg should use _parse_disjunction
1 parent 0c10f77 commit 2b4e3fd

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

sqlglot/dialects/bigquery.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -919,16 +919,12 @@ def _parse_make_interval(self) -> exp.MakeInterval:
919919
def _parse_approx_quantiles(self) -> t.Optional[exp.Expression]:
920920
# APPROX_QUANTILES([DISTINCT] expression, number [{IGNORE | RESPECT} NULLS])
921921
distinct = self._match(TokenType.DISTINCT)
922-
this = self._parse_assignment()
922+
this = self._parse_disjunction()
923923
if distinct:
924924
this = self.expression(exp.Distinct, expressions=[this])
925925

926-
if not self._match(TokenType.COMMA):
927-
self.raise_error(
928-
"Expected comma between expression and number of quantiles in APPROX_QUANTILES"
929-
)
930-
931-
expression = self._parse_assignment()
926+
self._match(TokenType.COMMA)
927+
expression = self._parse_disjunction()
932928
if not expression:
933929
self.raise_error("Expected number of quantiles argument in APPROX_QUANTILES")
934930

tests/dialects/test_bigquery.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3448,6 +3448,8 @@ def test_round(self):
34483448

34493449
def test_approx_quantiles(self):
34503450
self.validate_identity("APPROX_QUANTILES(x, 2)")
3451+
self.validate_identity("APPROX_QUANTILES(FALSE OR TRUE, 2)")
3452+
self.validate_identity("APPROX_QUANTILES((SELECT 1 AS val), CAST(2.1 AS INT64))")
34513453
self.validate_identity("APPROX_QUANTILES(DISTINCT x, 2)")
34523454
self.validate_identity("APPROX_QUANTILES(x, 2 RESPECT NULLS)")
34533455
self.validate_identity("APPROX_QUANTILES(x, 2 IGNORE NULLS)")

0 commit comments

Comments
 (0)