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
3 changes: 3 additions & 0 deletions crates/squawk_parser/src/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2559,6 +2559,9 @@ const COMPOUND_SELECT_FIRST: TokenSet = TokenSet::new(&[UNION_KW, INTERSECT_KW,
// [ SEARCH { BREADTH | DEPTH } FIRST BY column_name [, ...] SET search_seq_col_name ]
// [ CYCLE column_name [, ...] SET cycle_mark_col_name [ TO cycle_mark_value DEFAULT cycle_mark_default ] USING cycle_path_col_name ]
fn with_query(p: &mut Parser<'_>) -> CompletedMarker {
if p.at(WITH_KW) {
p.err_and_bump("unexpected WITH");
}
let m = p.start();
name(p);
opt_column_list_with(p, ColumnDefKind::Name);
Expand Down
5 changes: 5 additions & 0 deletions crates/squawk_parser/tests/data/err/select_cte.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ with t as (select 1)
search depth first by a, b c set ordercol
select * from t order by ordercol;

-- extra with
with t as (select 1),
with f as (select 2)
select * from t;

with
a as (
select 1
Expand Down
69 changes: 66 additions & 3 deletions crates/squawk_parser/tests/snapshots/tests__select_cte_err.snap
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,65 @@ SOURCE_FILE
IDENT "ordercol"
SEMICOLON ";"
WHITESPACE "\n\n"
COMMENT "-- extra with"
WHITESPACE "\n"
SELECT
WITH_CLAUSE
WITH_KW "with"
WHITESPACE " "
WITH_TABLE
NAME
IDENT "t"
WHITESPACE " "
AS_KW "as"
WHITESPACE " "
L_PAREN "("
SELECT
SELECT_CLAUSE
SELECT_KW "select"
WHITESPACE " "
TARGET_LIST
TARGET
LITERAL
INT_NUMBER "1"
R_PAREN ")"
COMMA ","
WHITESPACE "\n"
ERROR
WITH_KW "with"
WHITESPACE " "
WITH_TABLE
NAME
IDENT "f"
WHITESPACE " "
AS_KW "as"
WHITESPACE " "
L_PAREN "("
SELECT
SELECT_CLAUSE
SELECT_KW "select"
WHITESPACE " "
TARGET_LIST
TARGET
LITERAL
INT_NUMBER "2"
R_PAREN ")"
WHITESPACE "\n"
SELECT_CLAUSE
SELECT_KW "select"
WHITESPACE " "
TARGET_LIST
TARGET
STAR "*"
WHITESPACE " "
FROM_CLAUSE
FROM_KW "from"
WHITESPACE " "
FROM_ITEM
NAME_REF
IDENT "t"
SEMICOLON ";"
WHITESPACE "\n\n"
SELECT
WITH_CLAUSE
WITH_KW "with"
Expand Down Expand Up @@ -345,15 +404,19 @@ error[syntax-error]: expected COMMA
╭▸
13 │ search depth first by a, b c set ordercol
╰╴ ━
error[syntax-error]: unexpected WITH
╭▸
18 │ with f as (select 2)
╰╴━
error[syntax-error]: missing comma
╭▸
19 │ ) -- <-- missing a comma
24 │ ) -- <-- missing a comma
╰╴ ━
error[syntax-error]: missing comma
╭▸
29 │ ) -- <-- missing a comma
34 │ ) -- <-- missing a comma
╰╴ ━
error[syntax-error]: unexpected comma
╭▸
38 │ ), -- <-- extra comma
43 │ ), -- <-- extra comma
╰╴ ━
Loading