Skip to content

Commit d0cdb97

Browse files
committed
Skip empty statements in parser and test infrastructure
- Parser: Skip leading semicolons in ParseStatements to handle empty statements (just ';') gracefully - Test: Skip empty semicolon statements in splitStatements to match ClickHouse behavior which doesn't count empty statements This fixes the statement numbering mismatch that caused 03036_join_filter_push_down_equivalent_sets to fail, and also fixes 02155_multiple_inserts_for_formats_with_suffix.
1 parent 588e73b commit d0cdb97

File tree

4 files changed

+12
-53
lines changed

4 files changed

+12
-53
lines changed

parser/parser.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ func (p *Parser) ParseStatements(ctx context.Context) ([]ast.Statement, error) {
8989
default:
9090
}
9191

92+
// Skip leading semicolons (empty statements)
93+
for p.currentIs(token.SEMICOLON) {
94+
p.nextToken()
95+
}
96+
if p.currentIs(token.EOF) {
97+
break
98+
}
99+
92100
stmt := p.parseStatement()
93101
if stmt != nil {
94102
statements = append(statements, stmt)

parser/parser_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ func splitStatements(content string) []string {
5858
// Check if statement is complete (ends with ;)
5959
if strings.HasSuffix(trimmed, ";") {
6060
stmt := strings.TrimSpace(current.String())
61-
if stmt != "" {
61+
// Skip empty statements (just semicolons or empty)
62+
if stmt != "" && stmt != ";" {
6263
statements = append(statements, stmt)
6364
}
6465
current.Reset()
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt22": true,
4-
"stmt23": true,
5-
"stmt24": true,
6-
"stmt25": true,
7-
"stmt26": true,
8-
"stmt27": true,
9-
"stmt28": true,
10-
"stmt29": true,
11-
"stmt30": true
12-
}
13-
}
1+
{}
Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt15": true,
4-
"stmt16": true,
5-
"stmt17": true,
6-
"stmt18": true,
7-
"stmt19": true,
8-
"stmt20": true,
9-
"stmt21": true,
10-
"stmt22": true,
11-
"stmt23": true,
12-
"stmt24": true,
13-
"stmt25": true,
14-
"stmt26": true,
15-
"stmt27": true,
16-
"stmt28": true,
17-
"stmt29": true,
18-
"stmt30": true,
19-
"stmt31": true,
20-
"stmt32": true,
21-
"stmt33": true,
22-
"stmt34": true,
23-
"stmt35": true,
24-
"stmt36": true,
25-
"stmt37": true,
26-
"stmt38": true,
27-
"stmt39": true,
28-
"stmt40": true,
29-
"stmt41": true,
30-
"stmt42": true,
31-
"stmt43": true,
32-
"stmt44": true,
33-
"stmt45": true,
34-
"stmt46": true,
35-
"stmt47": true,
36-
"stmt48": true,
37-
"stmt49": true
38-
}
39-
}
1+
{}

0 commit comments

Comments
 (0)