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
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ orderByClause
;

orderByExpression
: expression order=(KW_ASC | KW_DESC)?
: (expression | columnNamePathAllowEmpty) order=(KW_ASC | KW_DESC)?
;

tableSources
Expand Down Expand Up @@ -1258,15 +1258,15 @@ groupByClause
;

havingClause
: KW_HAVING havingExpr=expression
: KW_HAVING (havingExpr=expression | columnNamePathAllowEmpty)
;

windowClause
: KW_WINDOW windowName KW_AS '(' windowSpec ')' (',' windowName KW_AS '(' windowSpec ')')*
;

groupByItem
: expression order=(KW_ASC | KW_DESC)?
: (expression | columnNamePathAllowEmpty) order=(KW_ASC | KW_DESC)?
;

limitClause
Expand Down Expand Up @@ -2431,13 +2431,14 @@ columnName
;

columnNamePath
: uid (dottedId dottedId?)?
| .? dottedId dottedId?
: uid (dottedId dottedId?)? # columnNamePath_default
| .? dottedId dottedId? # columnNamePath_dotted
| uid DOT {this.shouldMatchEmpty()}? emptyColumn # columnNamePath_dot_empty
;

columnNamePathAllowEmpty
: {this.shouldMatchEmpty()}? emptyColumn
| uid (dottedId dottedId?)?
: columnNamePath
| {this.shouldMatchEmpty()}? emptyColumn
;

tableSpaceNameCreate
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ options {
superClass=SQLParserBase;
}

@parser::members {
notEntityCollecting(): boolean {
return !this.entityCollecting;
}
}

@header {
import { SQLParserBase } from '../SQLParserBase';
}
Expand Down Expand Up @@ -380,10 +386,19 @@ joinType
;

joinCriteria
: KW_ON booleanExpression
: KW_ON (joinColumnEquality | {this.notEntityCollecting()}? booleanExpression)
| KW_USING '(' identifier (',' identifier)* ')'
;

joinColumnEquality
: left=joinColumnReference EQ right=joinColumnReference
;

joinColumnReference
: identifier DOT {this.entityCollecting}? emptyColumn
| columnName
;

sampledRelation
: patternRecognition (KW_TABLESAMPLE sampleType '(' percentage=expression ')')?
;
Expand Down Expand Up @@ -1039,6 +1054,10 @@ columnRef
| {this.shouldMatchEmpty()}?
;

emptyColumn
:
;

columnName
: qualifiedName
;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/mysql/MySqlParser.interp

Large diffs are not rendered by default.

Loading
Loading