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

clickhouse: add support for LIMIT BY #977

Merged
merged 1 commit into from
Oct 2, 2023

Conversation

lustefaniak
Copy link
Contributor

@lustefaniak lustefaniak commented Sep 24, 2023

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you (again) @lustefaniak -- looks very nice.

@@ -5434,6 +5436,13 @@ impl<'a> Parser<'a> {
}
}

let limit_by =
if dialect_of!(self is ClickHouseDialect) && self.parse_keyword(Keyword::BY) {
Copy link
Contributor

Choose a reason for hiding this comment

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

in general I think we try to have GenericDialect support the union of all sql dialects, if possible. So this might be something like

Suggested change
if dialect_of!(self is ClickHouseDialect) && self.parse_keyword(Keyword::BY) {
if dialect_of!(self is ClickHouseDialect | GenericDialect) && self.parse_keyword(Keyword::BY) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, good to know ;) I added tests testing both ClickhousDialect and GenericDialect

@@ -336,6 +336,13 @@ fn parse_create_table() {
);
}

#[test]
fn parse_limit_by() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also please add a test for the multi-column form (e.g. LIMIT BY asset, class or similar`)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @lustefaniak . This looks really nice

@alamb alamb merged commit 2786c7e into apache:main Oct 2, 2023
10 checks passed
@lustefaniak lustefaniak deleted the clickhouse-limit-by branch October 2, 2023 18:23
serprex pushed a commit to serprex/sqlparser-rs that referenced this pull request Nov 6, 2023
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