fix: #478 column completion and incomplete SELECT validate by Cythia828 · Pull Request #479 · DTStack/dt-sql-parser · GitHub
Skip to content
Open
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
15 changes: 8 additions & 7 deletions src/grammar/mysql/MySqlParser.g4
19 changes: 16 additions & 3 deletions src/grammar/postgresql/PostgreSqlParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ options {
superClass=SQLParserBase;
}

@parser::members {
isFollowedByInto(): boolean {
return this.tokenStream.LA(1) === PostgreSqlParser.KW_INTO;
}

isFollowedByEnd(): boolean {
const la = this.tokenStream.LA(1);
return la === PostgreSqlParser.SEMI || la === PostgreSqlParser.EOF;
}
}

@header {
import { SQLParserBase } from '../SQLParserBase';
}
Expand Down Expand Up @@ -2629,7 +2640,8 @@ optIndirection
;

targetList
: targetEl (COMMA targetEl)*
: {this.isFollowedByInto() || this.isFollowedByEnd()}?
| targetEl (COMMA targetEl)*
;

targetEl
Expand Down Expand Up @@ -2735,7 +2747,8 @@ columnName
;

columnNamePath
: colId optIndirection
: colId optIndirection # columnNamePath_default
| colId DOT {this.shouldMatchEmpty()}? emptyColumn # columnNamePath_dot_empty
;

columnNameCreate
Expand Down Expand Up @@ -3628,5 +3641,5 @@ anyIdentifier
;

sqlExpression
: targetList? intoClause? fromClause? whereClause? groupClause? havingClause? windowClause?
: targetList intoClause? fromClause? whereClause? groupClause? havingClause? windowClause?
;
21 changes: 20 additions & 1 deletion src/grammar/trino/TrinoSql.g4
2 changes: 1 addition & 1 deletion src/lib/mysql/MySqlParser.interp

Large diffs are not rendered by default.

Loading
Loading