Skip to content
Draft
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
22 changes: 18 additions & 4 deletions src/grammar/flink/FlinkSqlParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,24 @@ columnNameCreate
| expression
;

emptyColumn
:
;

columnName
: uid
| {this.shouldMatchEmpty()}?
: uidAllowEmpty
| {this.shouldMatchEmpty()}? emptyColumn
;

columnNamePath
: uid
;

columnNamePathAllowEmpty
: uidAllowEmpty
| {this.shouldMatchEmpty()}? emptyColumn
;

columnNameList
: LR_BRACKET columnName (COMMA columnName)* RR_BRACKET
;
Expand Down Expand Up @@ -614,12 +623,12 @@ columnDescriptor
;

joinCondition
: KW_ON booleanExpression
: KW_ON (booleanExpression | columnNamePathAllowEmpty (EQUAL_SYMBOL columnNamePathAllowEmpty)?)
| KW_USING columnNameList
;

whereClause
: KW_WHERE booleanExpression
: KW_WHERE (booleanExpression | columnNamePathAllowEmpty)
;

groupByClause
Expand Down Expand Up @@ -983,6 +992,11 @@ uid
: identifier (DOT identifier)*
;

uidAllowEmpty
: identifier (DOT identifier)*
| {this.shouldMatchEmpty()}? identifier DOT emptyColumn
;

withOption
: KW_WITH tablePropertyList
;
Expand Down
27 changes: 22 additions & 5 deletions src/grammar/hive/HiveSqlParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -754,14 +754,19 @@ columnNameList
;

columnName
: poolPath
| {this.shouldMatchEmpty()}?
: poolPathAllowEmpty
| {this.shouldMatchEmpty()}? emptyColumn
;

columnNamePath
: poolPath
;

columnNamePathAllowEmpty
: poolPathAllowEmpty
| {this.shouldMatchEmpty()}? emptyColumn
;

columnNameCreate
: id_
;
Expand Down Expand Up @@ -1346,7 +1351,10 @@ atomjoinSource

joinSource
: atomjoinSource (
joinToken joinSourcePart (KW_ON expression | KW_USING columnParenthesesList)?
joinToken joinSourcePart (
KW_ON (expression | columnNamePathAllowEmpty (EQUAL columnNamePathAllowEmpty)?)
| KW_USING columnParenthesesList
)?
)*
;

Expand Down Expand Up @@ -1469,7 +1477,7 @@ Rules for parsing whereClause
where a=b and ...
*/
whereClause
: KW_WHERE expression
: KW_WHERE (expression | columnNamePathAllowEmpty)
;

/**
Expand Down Expand Up @@ -1600,7 +1608,7 @@ groupingSetExpression
;

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

qualifyClause
Expand Down Expand Up @@ -2425,10 +2433,19 @@ decimal
| KW_NUMERIC
;

emptyColumn
:
;

poolPath
: id_ (DOT id_)*
;

poolPathAllowEmpty
: id_ (DOT id_)*
| {this.shouldMatchEmpty()}? id_ (DOT emptyColumn)*
;

triggerAtomExpression
: id_ GREATERTHAN (Number | StringLiteral)
;
Expand Down
24 changes: 19 additions & 5 deletions src/grammar/impala/ImpalaSqlParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -558,15 +558,24 @@ functionNamePath
| qualifiedName
;

emptyColumn
:
;

columnNamePath
: qualifiedName
| {this.shouldMatchEmpty()}?
: {this.shouldMatchEmpty()}? emptyColumn
| qualifiedNameAllowEmpty
;

columnName
: qualifiedName
;

columnNameAllowEmpty
: {this.shouldMatchEmpty()}? emptyColumn
| qualifiedNameAllowEmpty
;

tableOrViewPath
: tableNamePath
| viewNamePath
Expand Down Expand Up @@ -781,11 +790,11 @@ selectList
;

whereClause
: KW_WHERE where=booleanExpression
: KW_WHERE (where=booleanExpression | columnNameAllowEmpty)
;

havingClause
: KW_HAVING having=booleanExpression
: KW_HAVING (having=booleanExpression | columnNameAllowEmpty)
;

groupBy
Expand Down Expand Up @@ -854,7 +863,7 @@ joinType
;

joinCriteria
: KW_ON booleanExpression
: KW_ON (booleanExpression | columnNameAllowEmpty)
| KW_USING LPAREN identifier (COMMA identifier)* RPAREN
;

Expand Down Expand Up @@ -1149,6 +1158,11 @@ qualifiedName
: identifier (DOT identifier)*
;

qualifiedNameAllowEmpty
: {this.shouldMatchEmpty()}? (identifier DOT emptyColumn | emptyColumn)
| identifier (DOT identifier)*
;

principal
: KW_ROLE identifier # rolePrincipal
| KW_USER identifier # userPrincipal
Expand Down
28 changes: 24 additions & 4 deletions src/grammar/mysql/MySqlParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ joinPart
;

joinSpec
: (KW_ON expression)
: (KW_ON (expression | columnNamePathAllowEmpty))
| KW_USING '(' columnNames ')'
;

Expand Down Expand Up @@ -1249,7 +1249,7 @@ selectLinesInto
;

fromClause
: (KW_FROM tableSources)? (KW_WHERE whereExpr=expression)?
: (KW_FROM tableSources)? (KW_WHERE (whereExpr=expression | columnNamePathAllowEmpty))?
;

groupByClause
Expand Down Expand Up @@ -2419,10 +2419,24 @@ columnNames
: columnName (',' columnName)*
;

emptyColumn
:
;

columnName
: uid (dottedIdAllowEmpty dottedIdAllowEmpty?)?
| .? dottedId dottedId?
| {this.shouldMatchEmpty()}? emptyColumn
;

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

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

tableSpaceNameCreate
Expand Down Expand Up @@ -2560,6 +2574,12 @@ dottedId
| '.' uid
;

dottedIdAllowEmpty
: DOT ID
| '.' uid
| {this.shouldMatchEmpty()}? DOT emptyColumn
;

decimalLiteral
: DECIMAL_LITERAL
| ZERO_DECIMAL
Expand Down Expand Up @@ -2998,7 +3018,7 @@ expressionAtom
| left=expressionAtom jsonOperator right=expressionAtom # jsonExpressionAtom
| left=expressionAtom bitOperator right=expressionAtom # bitExpressionAtom
| left=expressionAtom mathOperator right=expressionAtom # mathExpressionAtom
| columnName # columnNameExpressionAtom
| columnNamePath # columnNameExpressionAtom
;

unaryOperator
Expand Down
7 changes: 6 additions & 1 deletion src/grammar/postgresql/PostgreSqlParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -2722,13 +2722,18 @@ procedureNameCreate
| colId indirection
;

emptyColumn
:
;

columnName
: colId optIndirection
| {this.shouldMatchEmpty()}?
| {this.shouldMatchEmpty()}? (colId DOT emptyColumn | emptyColumn)
;

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

columnNameCreate
Expand Down
20 changes: 17 additions & 3 deletions src/grammar/spark/SparkSqlParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -413,15 +413,24 @@ viewName
: viewIdentifier
;

emptyColumn
:
;

columnName
: multipartIdentifier
| {this.shouldMatchEmpty()}?
: multipartIdentifierAllowEmpty
| {this.shouldMatchEmpty()}? emptyColumn
;

columnNamePath
: multipartIdentifier
;

columnNamePathAllowEmpty
: multipartIdentifierAllowEmpty
| {this.shouldMatchEmpty()}? emptyColumn
;

columnNameSeq
: columnName (COMMA columnName)*
;
Expand Down Expand Up @@ -680,7 +689,7 @@ joinType
;

joinCriteria
: KW_ON booleanExpression
: KW_ON (booleanExpression | columnNamePathAllowEmpty (EQ columnNamePathAllowEmpty)?)
| KW_USING identifierList
;

Expand Down Expand Up @@ -804,6 +813,11 @@ multipartIdentifier
: parts+=errorCapturingIdentifier (DOT parts+=errorCapturingIdentifier)*
;

multipartIdentifierAllowEmpty
: multipartIdentifier
| {this.shouldMatchEmpty()}? multipartIdentifier DOT emptyColumn
;

multipartIdentifierPropertyList
: multipartIdentifierProperty (COMMA multipartIdentifierProperty)*
;
Expand Down
5 changes: 4 additions & 1 deletion src/lib/flink/FlinkSqlParser.interp

Large diffs are not rendered by default.

Loading
Loading