Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/squawk_ide/src/expand_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ const DELIMITED_LIST_KINDS: &[SyntaxKind] = &[
SyntaxKind::ATTRIBUTE_LIST,
SyntaxKind::COLUMN_LIST,
SyntaxKind::CONSTRAINT_EXCLUSION_LIST,
SyntaxKind::GROUP_BY_LIST,
SyntaxKind::JSON_TABLE_COLUMN_LIST,
SyntaxKind::OPTIONS_LIST,
SyntaxKind::PARAM_LIST,
SyntaxKind::PARTITION_ITEM_LIST,
SyntaxKind::ROW_LIST,
SyntaxKind::SET_OPTIONS_LIST,
SyntaxKind::SORT_BY_LIST,
SyntaxKind::TABLE_ARG_LIST,
SyntaxKind::TABLE_LIST,
SyntaxKind::TARGET_LIST,
Expand Down
2 changes: 2 additions & 0 deletions crates/squawk_parser/src/generated/syntax_kind.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions crates/squawk_parser/src/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2727,14 +2727,20 @@ fn opt_order_by_clause(p: &mut Parser<'_>) -> bool {
return false;
}
p.expect(BY_KW);
sort_by_list(p);
m.complete(p, ORDER_BY_CLAUSE);
true
}

fn sort_by_list(p: &mut Parser<'_>) {
let m = p.start();
while !p.at(EOF) {
sort_by(p);
if !p.eat(COMMA) {
break;
}
}
m.complete(p, ORDER_BY_CLAUSE);
true
m.complete(p, SORT_BY_LIST);
}

fn sort_by(p: &mut Parser<'_>) {
Expand Down Expand Up @@ -4334,6 +4340,7 @@ fn group_by_list(p: &mut Parser<'_>) {
// ambiguity, a GROUP BY name will be interpreted as an input-column name
// rather than an output column name.

let m = p.start();
while !p.at(EOF) && !p.at(SEMICOLON) {
if opt_group_by_item(p).is_none() {
p.error("expected group by item");
Expand All @@ -4342,6 +4349,7 @@ fn group_by_list(p: &mut Parser<'_>) {
break;
}
}
m.complete(p, GROUP_BY_LIST);
}

const GROUP_BY_ITEM_FIRST: TokenSet =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ SOURCE_FILE
WHITESPACE " "
BY_KW "by"
WHITESPACE " "
SORT_BY
NAME_REF
IDENT "y"
WHITESPACE " "
SORT_DESC
DESC_KW "desc"
SORT_BY_LIST
SORT_BY
NAME_REF
IDENT "y"
WHITESPACE " "
SORT_DESC
DESC_KW "desc"
SEMICOLON ";"
WHITESPACE "\n"
22 changes: 12 additions & 10 deletions crates/squawk_parser/tests/snapshots/tests__delete_ok.snap
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,10 @@ SOURCE_FILE
WHITESPACE " "
BY_KW "by"
WHITESPACE " "
GROUPING_EXPR
NAME_REF
IDENT "user_id"
GROUP_BY_LIST
GROUPING_EXPR
NAME_REF
IDENT "user_id"
R_PAREN ")"
WHITESPACE " "
ALIAS
Expand Down Expand Up @@ -999,13 +1000,14 @@ SOURCE_FILE
WHITESPACE " "
BY_KW "BY"
WHITESPACE " "
SORT_BY
FIELD_EXPR
NAME_REF
IDENT "l"
DOT "."
NAME_REF
IDENT "creation_date"
SORT_BY_LIST
SORT_BY
FIELD_EXPR
NAME_REF
IDENT "l"
DOT "."
NAME_REF
IDENT "creation_date"
WHITESPACE "\n "
LOCKING_CLAUSE
FOR_KW "FOR"
Expand Down
21 changes: 12 additions & 9 deletions crates/squawk_parser/tests/snapshots/tests__explain_ok.snap
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,10 @@ SOURCE_FILE
WHITESPACE " "
BY_KW "BY"
WHITESPACE " "
GROUPING_EXPR
NAME_REF
IDENT "foo"
GROUP_BY_LIST
GROUPING_EXPR
NAME_REF
IDENT "foo"
SEMICOLON ";"
WHITESPACE "\n\n"
EXPLAIN
Expand Down Expand Up @@ -484,9 +485,10 @@ SOURCE_FILE
WHITESPACE " "
BY_KW "BY"
WHITESPACE " "
GROUPING_EXPR
NAME_REF
IDENT "foo"
GROUP_BY_LIST
GROUPING_EXPR
NAME_REF
IDENT "foo"
SEMICOLON ";"
WHITESPACE "\n\n"
COMMENT "-- doc_example_8"
Expand Down Expand Up @@ -561,9 +563,10 @@ SOURCE_FILE
WHITESPACE " "
BY_KW "BY"
WHITESPACE " "
GROUPING_EXPR
NAME_REF
IDENT "foo"
GROUP_BY_LIST
GROUPING_EXPR
NAME_REF
IDENT "foo"
SEMICOLON ";"
WHITESPACE "\n\n"
COMMENT "-- parens_select"
Expand Down
Loading
Loading