feat(flink): add grammar rules that pass the test
This commit is contained in:
parent
da9660c6fe
commit
afef8e6d72
@ -157,19 +157,27 @@ valuesRowDefinition
|
|||||||
// Select statements
|
// Select statements
|
||||||
|
|
||||||
queryStatement
|
queryStatement
|
||||||
:
|
: (
|
||||||
|
selectClause | selectStatement
|
||||||
|
) orderByCaluse? limitClause
|
||||||
;
|
;
|
||||||
|
|
||||||
selectStatement
|
selectStatement
|
||||||
: SELECT setQuantifier?
|
: selectClause fromClause whereClause? groupByClause? havingClause?
|
||||||
(ASTERISK_SIGN | projectItemDefinition (COMMA projectItemDefinition)*)
|
;
|
||||||
FROM tableExpression
|
|
||||||
|
selectClause
|
||||||
|
: SELECT setQuantifier? (ASTERISK_SIGN | projectItemDefinition (COMMA projectItemDefinition)*)
|
||||||
;
|
;
|
||||||
|
|
||||||
projectItemDefinition
|
projectItemDefinition
|
||||||
: expression (AS? uid)? | uid '.' '*'
|
: expression (AS? uid)? | uid '.' '*'
|
||||||
;
|
;
|
||||||
|
|
||||||
|
fromClause
|
||||||
|
: FROM tableExpression
|
||||||
|
;
|
||||||
|
|
||||||
tableExpression
|
tableExpression
|
||||||
: tableReference (COMMA tableReference)*
|
: tableReference (COMMA tableReference)*
|
||||||
;
|
;
|
||||||
@ -182,6 +190,39 @@ tablePrimary
|
|||||||
: TABLE? uid
|
: TABLE? uid
|
||||||
;
|
;
|
||||||
|
|
||||||
|
whereClause
|
||||||
|
: WHERE booleanExpression
|
||||||
|
;
|
||||||
|
|
||||||
|
groupByClause
|
||||||
|
: GROUP BY groupItemDefinition (COMMA groupItemDefinition)*
|
||||||
|
;
|
||||||
|
|
||||||
|
groupItemDefinition
|
||||||
|
: expression
|
||||||
|
| LR_BRACKET RR_BRACKET
|
||||||
|
| LR_BRACKET expression (COMMA expression)* RR_BRACKET
|
||||||
|
| CUBE LR_BRACKET expression (COMMA expression)* RR_BRACKET
|
||||||
|
| ROLLUP LR_BRACKET expression (COMMA expression)* RR_BRACKET
|
||||||
|
| GROUPING SETS LR_BRACKET groupItemDefinition (COMMA groupItemDefinition)* RR_BRACKET
|
||||||
|
;
|
||||||
|
|
||||||
|
havingClause
|
||||||
|
: HAVING booleanExpression
|
||||||
|
;
|
||||||
|
|
||||||
|
orderByCaluse
|
||||||
|
: ORDER BY orderItemDefition (COMMA orderItemDefition)*
|
||||||
|
;
|
||||||
|
|
||||||
|
orderItemDefition
|
||||||
|
: expression (ASC | DESC)
|
||||||
|
;
|
||||||
|
|
||||||
|
limitClause
|
||||||
|
: LIMIT (ALL | limit=expression)
|
||||||
|
;
|
||||||
|
|
||||||
// expression
|
// expression
|
||||||
|
|
||||||
expression
|
expression
|
||||||
@ -227,7 +268,7 @@ primaryExpression
|
|||||||
| FIRST '(' expression (IGNORE NULLS)? ')' #first
|
| FIRST '(' expression (IGNORE NULLS)? ')' #first
|
||||||
| LAST '(' expression (IGNORE NULLS)? ')' #last
|
| LAST '(' expression (IGNORE NULLS)? ')' #last
|
||||||
| POSITION '(' substr=valueExpression IN str=valueExpression ')' #position
|
| POSITION '(' substr=valueExpression IN str=valueExpression ')' #position
|
||||||
| constant #constantDefault
|
// | constant #constantDefault
|
||||||
| ASTERISK #star
|
| ASTERISK #star
|
||||||
// | qualifiedName '.' ASTERISK #star
|
// | qualifiedName '.' ASTERISK #star
|
||||||
// | '(' namedExpression (',' namedExpression)+ ')' #rowConstructor
|
// | '(' namedExpression (',' namedExpression)+ ')' #rowConstructor
|
||||||
@ -236,8 +277,8 @@ primaryExpression
|
|||||||
// (FILTER '(' WHERE where=booleanExpression ')')? (OVER windowSpec)? #functionCall
|
// (FILTER '(' WHERE where=booleanExpression ')')? (OVER windowSpec)? #functionCall
|
||||||
// | identifier '->' expression #lambda
|
// | identifier '->' expression #lambda
|
||||||
// | '(' identifier (',' identifier)+ ')' '->' expression #lambda
|
// | '(' identifier (',' identifier)+ ')' '->' expression #lambda
|
||||||
| value=primaryExpression LS_BRACKET index=valueExpression RS_BRACKET #subscript
|
// | value=primaryExpression LS_BRACKET index=valueExpression RS_BRACKET #subscript
|
||||||
// | identifier #columnReference
|
| identifier #columnReference
|
||||||
// | base=primaryExpression '.' fieldName=identifier #dereference
|
// | base=primaryExpression '.' fieldName=identifier #dereference
|
||||||
| '(' expression ')' #parenthesizedExpression
|
| '(' expression ')' #parenthesizedExpression
|
||||||
// | EXTRACT '(' field=identifier FROM source=valueExpression ')' #extract
|
// | EXTRACT '(' field=identifier FROM source=valueExpression ')' #extract
|
||||||
@ -685,9 +726,6 @@ RR_BRACKET: ')';
|
|||||||
COMMA: ',';
|
COMMA: ',';
|
||||||
SEMICOLON: ';';
|
SEMICOLON: ';';
|
||||||
AT_SIGN: '@';
|
AT_SIGN: '@';
|
||||||
ZERO_DECIMAL: '0';
|
|
||||||
ONE_DECIMAL: '1';
|
|
||||||
TWO_DECIMAL: '2';
|
|
||||||
SINGLE_QUOTE_SYMB: '\'';
|
SINGLE_QUOTE_SYMB: '\'';
|
||||||
DOUBLE_QUOTE_SYMB: '"';
|
DOUBLE_QUOTE_SYMB: '"';
|
||||||
REVERSE_QUOTE_SYMB: '`';
|
REVERSE_QUOTE_SYMB: '`';
|
||||||
|
Loading…
Reference in New Issue
Block a user