Skip to content
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

Fix(clickhouse): don't generate parentheses, match R_PAREN conditionally #2332

Merged
merged 2 commits into from
Sep 27, 2023

Conversation

Comment on lines +2745 to +2747
self._parse_factor()
if self._match(TokenType.NUMBER, advance=False)
else self._parse_primary()
Copy link
Collaborator Author

@georgesittas georgesittas Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This turned out a bit awkward.. the motivation was to support stuff like SAMPLE 1 / 10 (shown as an example in ClickHouse's docs). The thing is that _parse_term doesn't suffice, because DuckDB also allows SAMPLE 10%, so the parser would try to parse this into a Mod and fail due to not finding a RHS. We also need to ensure we're calling _parse_factor against a number because otherwise it might consume the BUCKET token in SELECT a FROM test TABLESAMPLE (BUCKET 1 OUT OF 5 ON x).

@georgesittas georgesittas merged commit 58c7849 into main Sep 27, 2023
@georgesittas georgesittas deleted the jo/clickhouse_sample_fix branch September 27, 2023 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants