-
Notifications
You must be signed in to change notification settings - Fork 1k
Feat: transpile BQ APPROX_QUANTILES to DuckDB #6349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
sqlglot/dialects/bigquery.py
Outdated
| def _parse_approx_quantiles(self) -> t.Optional[exp.Expression]: | ||
| # APPROX_QUANTILES([DISTINCT] expression, number [{IGNORE | RESPECT} NULLS]) | ||
| distinct = self._match(TokenType.DISTINCT) | ||
| this = self._parse_assignment() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you choose parse_assignment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user error - i was walking through the parsing steps for a subquery, hit _parse_assignment for a where and incorrectly used that more broadly
should this be _parse_expression or _parse_lambda?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is a lambda allowed here? or an alias or a disjunction? most likely you want bitwise, but do your research
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it accepts TRUE OR FALSE, so will use _parse_disjunction
| distinct = self._match(TokenType.DISTINCT) | ||
| this = self._parse_assignment() | ||
| if distinct: | ||
| this = self.expression(exp.Distinct, expressions=[this]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should probably be an argument to approx_quantiles as opposed to first class distinct node, @georgesittas what do you think
sqlglot/dialects/bigquery.py
Outdated
| "Expected comma between expression and number of quantiles in APPROX_QUANTILES" | ||
| ) | ||
|
|
||
| expression = self._parse_assignment() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user error - i was walking through the parsing steps for a subquery, hit _parse_assignment for a where and incorrectly used that more broadly
should this be _parse_expression or _parse_lambda?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one accepts only positive integer literals and expr like CAST(2.1 AS INTEGER)
_parse_type aligns with that (but is strict and enforces number positivity)
i'll relax up to _parse_bitwise
b25bcd4 to
726e0df
Compare
Notes:
RESPECT NULLSoption