Skip to content

Commit 1ead420

Browse files
authored
parser: pg regression suite tidying (#515)
Now we keep snapshots of the errors as well as having a test keep track of files that have errors and the error count. We can gradually burn down the files & error counts! Also fix a few panics that the regression suite had with select
1 parent cb2fe78 commit 1ead420

File tree

109 files changed

+12517
-31
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+12517
-31
lines changed

.github/workflows/rust.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,9 @@ jobs:
388388
- name: Cache
389389
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # pin@v2
390390

391+
- name: Install ripgrep
392+
run: cargo install ripgrep
393+
391394
- name: Test
392395
run: ./s/test
393396

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/squawk_parser/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ insta.workspace = true
2020
dir-test.workspace = true
2121
camino.workspace = true
2222
pg_query.workspace = true
23+
xshell.workspace = true
2324

2425
[lints]
2526
workspace = true

crates/squawk_parser/src/grammar.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4163,8 +4163,8 @@ const EXPR_FIRST: TokenSet = LHS_FIRST;
41634163
const ATTRIBUTE_FIRST: TokenSet = TokenSet::new(&[POUND, GROUP_KW]);
41644164

41654165
const TARGET_FOLLOW: TokenSet = TokenSet::new(&[
4166-
FROM_KW, WHERE_KW, LIMIT_KW, ORDER_KW, OFFSET_KW, GROUP_KW, HAVING_KW, WINDOW_KW, HAVING_KW,
4167-
FETCH_KW, FOR_KW, R_PAREN, R_BRACK,
4166+
SELECT_KW, FROM_KW, WHERE_KW, LIMIT_KW, ORDER_KW, OFFSET_KW, GROUP_KW, INTO_KW, HAVING_KW,
4167+
WINDOW_KW, HAVING_KW, FETCH_KW, FOR_KW, R_PAREN, R_BRACK,
41684168
])
41694169
.union(COMPOUND_SELECT_FIRST);
41704170

@@ -4216,7 +4216,7 @@ fn opt_as_col_label(p: &mut Parser<'_>) -> bool {
42164216
}
42174217

42184218
fn opt_target_list(p: &mut Parser) -> Option<CompletedMarker> {
4219-
if !p.at_ts(TARGET_LIST_START) || p.at(SELECT_KW) {
4219+
if !p.at_ts(TARGET_LIST_START) || p.at_ts(TARGET_FOLLOW) {
42204220
return None;
42214221
}
42224222
let m = p.start();

crates/squawk_parser/tests/data/ok/select_funcs.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ select json_array(a absent on null);
127127
select json_array(a absent on null returning foo format json);
128128
select json_array(1, true, json '{"a":null}');
129129
select json_array(1, b, '3' format json, 4);
130+
-- regression test
131+
select json_array(select from t);
132+
select json_array(select into t from u);
130133

131134
-- query_expression
132135
select json_array(select 1);

crates/squawk_parser/tests/snapshots/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
source: crates/squawk_parser/tests/tests.rs
3+
input_file: crates/squawk_parser/tests/data/regression_suite/alter_generic.sql
4+
---
5+
ERROR@15151: expected R_PAREN
6+
ERROR@15152: expected OPERATOR, or FUNCTION
7+
ERROR@15152: expected SEMICOLON
8+
ERROR@15153: expected command, found IDENT
9+
ERROR@15157: expected command, found R_PAREN
10+
ERROR@21020: expected type name
11+
ERROR@21020: expected R_PAREN
12+
ERROR@21020: expected SEMICOLON
13+
ERROR@21020: expected command, found L_BRACK
14+
ERROR@21021: expected command, found R_BRACK
15+
ERROR@21022: expected command, found COMMA
16+
ERROR@21024: expected command, found IDENT
17+
ERROR@21028: expected command, found R_PAREN
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
---
2+
source: crates/squawk_parser/tests/tests.rs
3+
input_file: crates/squawk_parser/tests/data/regression_suite/alter_table.sql
4+
---
5+
ERROR@12719: expected VALID_KW
6+
ERROR@12719: expected SEMICOLON
7+
ERROR@12720: expected command, found ENFORCED_KW
8+
ERROR@15268: expected R_PAREN
9+
ERROR@15268: expected SEMICOLON
10+
ERROR@15269: expected command, found NOT_KW
11+
ERROR@15273: expected command, found VALID_KW
12+
ERROR@15278: expected command, found R_PAREN
13+
ERROR@33822: expected FOREIGN_KW
14+
ERROR@33822: expected KEY_KW
15+
ERROR@33822: expected column list
16+
ERROR@33822: expected REFERENCES_KW
17+
ERROR@33826: expected SEMICOLON
18+
ERROR@33827: expected command, found NULL_KW
19+
ERROR@33832: expected command, found IDENT
20+
ERROR@33835: expected command, found NOT_KW
21+
ERROR@33839: expected command, found VALID_KW
22+
ERROR@33940: expected FOREIGN_KW
23+
ERROR@33940: expected KEY_KW
24+
ERROR@33940: expected column list
25+
ERROR@33940: expected REFERENCES_KW
26+
ERROR@33944: expected SEMICOLON
27+
ERROR@33945: expected command, found NULL_KW
28+
ERROR@33950: expected command, found IDENT
29+
ERROR@38443: expected L_PAREN
30+
ERROR@38448: expected R_PAREN
31+
ERROR@38448: expected SEMICOLON
32+
ERROR@38449: expected command, found OIDS_KW
33+
ERROR@42440: expected command, found INT_NUMBER
34+
ERROR@42443: expected command, found INT_NUMBER
35+
ERROR@42446: expected command, found INT_NUMBER
36+
ERROR@42495: expected command, found INT_NUMBER
37+
ERROR@42498: expected command, found INT_NUMBER
38+
ERROR@42635: expected command, found INT_NUMBER
39+
ERROR@42638: expected command, found INT_NUMBER
40+
ERROR@43987: expected NULL_KW
41+
ERROR@43987: expected SEMICOLON
42+
ERROR@43988: expected command, found ENFORCED_KW
43+
ERROR@44078: expected NULL_KW
44+
ERROR@44078: expected SEMICOLON
45+
ERROR@44079: expected command, found ENFORCED_KW
46+
ERROR@44088: expected command, found ENFORCED_KW
47+
ERROR@67262: expected type name
48+
ERROR@67262: expected SEMICOLON
49+
ERROR@67262: expected command, found DOT
50+
ERROR@67263: expected command, found IDENT
51+
ERROR@67270: expected command, found INTEGER_KW
52+
ERROR@67278: expected command, found CHECK_KW
53+
ERROR@67284: expected command, found L_PAREN
54+
ERROR@67285: expected command, found VALUE_KW
55+
ERROR@67291: expected command, found R_ANGLE
56+
ERROR@67293: expected command, found INT_NUMBER
57+
ERROR@67294: expected command, found R_PAREN
58+
ERROR@67380: expected R_PAREN
59+
ERROR@67380: expected function option
60+
ERROR@67380: expected SEMICOLON
61+
ERROR@67380: expected command, found DOT
62+
ERROR@67381: expected command, found IDENT
63+
ERROR@67386: expected command, found COMMA
64+
ERROR@67388: expected command, found IDENT
65+
ERROR@67394: expected command, found DOT
66+
ERROR@67395: expected command, found IDENT
67+
ERROR@67400: expected command, found R_PAREN
68+
ERROR@67402: expected command, found RETURNS_KW
69+
ERROR@67410: expected command, found BOOLEAN_KW
70+
ERROR@67418: expected command, found LANGUAGE_KW
71+
ERROR@67427: expected command, found SQL_KW
72+
ERROR@67431: expected command, found AS_KW
73+
ERROR@67434: expected command, found STRING
74+
ERROR@68763: expected R_PAREN
75+
ERROR@68763: expected function option
76+
ERROR@68763: expected SEMICOLON
77+
ERROR@68763: expected command, found DOT
78+
ERROR@68764: expected command, found IDENT
79+
ERROR@68769: expected command, found COMMA
80+
ERROR@68771: expected command, found IDENT
81+
ERROR@68777: expected command, found DOT
82+
ERROR@68778: expected command, found IDENT
83+
ERROR@68783: expected command, found R_PAREN
84+
ERROR@68795: expected EQ
85+
ERROR@71700: expected type name
86+
ERROR@74909: expected FOREIGN_KW
87+
ERROR@74909: expected KEY_KW
88+
ERROR@74909: expected column list
89+
ERROR@74909: expected REFERENCES_KW
90+
ERROR@74913: expected R_PAREN
91+
ERROR@74913: expected SEMICOLON
92+
ERROR@74914: expected command, found NULL_KW
93+
ERROR@74919: expected command, found IDENT
94+
ERROR@74921: expected command, found COMMA
95+
ERROR@74925: expected command, found IDENT
96+
ERROR@74938: expected command, found INT_KW
97+
ERROR@74942: expected command, found CHECK_KW
98+
ERROR@74948: expected command, found L_PAREN
99+
ERROR@74949: expected command, found IDENT
100+
ERROR@74962: expected command, found R_ANGLE
101+
ERROR@74964: expected command, found INT_NUMBER
102+
ERROR@74965: expected command, found R_PAREN
103+
ERROR@74966: expected command, found COMMA
104+
ERROR@74970: expected command, found IDENT
105+
ERROR@74982: expected command, found INT_KW
106+
ERROR@74985: expected command, found COMMA
107+
ERROR@74989: expected command, found CONSTRAINT_KW
108+
ERROR@75000: expected command, found IDENT
109+
ERROR@75016: expected command, found PRIMARY_KW
110+
ERROR@75024: expected command, found KEY_KW
111+
ERROR@75028: expected command, found L_PAREN
112+
ERROR@75029: expected command, found IDENT
113+
ERROR@75031: expected command, found R_PAREN
114+
ERROR@75032: expected command, found R_PAREN
115+
ERROR@86438: expected name
116+
ERROR@86438: expected type name
117+
ERROR@86447: expected SEMICOLON
118+
ERROR@86448: expected command, found IDENT
119+
ERROR@91452: expected R_PAREN
120+
ERROR@91452: expected SEMICOLON
121+
ERROR@91453: expected command, found NO_KW
122+
ERROR@91456: expected command, found INHERIT_KW
123+
ERROR@91463: expected command, found COMMA
124+
ERROR@91466: expected command, found IDENT
125+
ERROR@91468: expected command, found CHAR_KW
126+
ERROR@91472: expected command, found L_PAREN
127+
ERROR@91473: expected command, found INT_NUMBER
128+
ERROR@91474: expected command, found R_PAREN
129+
ERROR@91476: expected command, found COLLATE_KW
130+
ERROR@91484: expected command, found IDENT
131+
ERROR@91487: expected command, found COMMA
132+
ERROR@91490: expected command, found CONSTRAINT_KW
133+
ERROR@91501: expected command, found IDENT
134+
ERROR@91509: expected command, found CHECK_KW
135+
ERROR@91515: expected command, found L_PAREN
136+
ERROR@91516: expected command, found IDENT
137+
ERROR@91518: expected command, found R_ANGLE
138+
ERROR@91520: expected command, found INT_NUMBER
139+
ERROR@91521: expected command, found R_PAREN
140+
ERROR@91523: expected command, found R_PAREN

0 commit comments

Comments
 (0)