mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
add support of window function in antlr grammar
This commit is contained in:
parent
746964af88
commit
693060552a
@ -35,6 +35,7 @@ CONSTRAINT: C O N S T R A I N T;
|
|||||||
CREATE: C R E A T E;
|
CREATE: C R E A T E;
|
||||||
CROSS: C R O S S;
|
CROSS: C R O S S;
|
||||||
CUBE: C U B E;
|
CUBE: C U B E;
|
||||||
|
CURRENT: C U R R E N T;
|
||||||
DATABASE: D A T A B A S E;
|
DATABASE: D A T A B A S E;
|
||||||
DATABASES: D A T A B A S E S;
|
DATABASES: D A T A B A S E S;
|
||||||
DATE: D A T E;
|
DATE: D A T E;
|
||||||
@ -65,6 +66,7 @@ FETCHES: F E T C H E S;
|
|||||||
FINAL: F I N A L;
|
FINAL: F I N A L;
|
||||||
FIRST: F I R S T;
|
FIRST: F I R S T;
|
||||||
FLUSH: F L U S H;
|
FLUSH: F L U S H;
|
||||||
|
FOLLOWING: F O L L O W I N G;
|
||||||
FOR: F O R;
|
FOR: F O R;
|
||||||
FORMAT: F O R M A T;
|
FORMAT: F O R M A T;
|
||||||
FREEZE: F R E E Z E;
|
FREEZE: F R E E Z E;
|
||||||
@ -125,8 +127,10 @@ OR: O R;
|
|||||||
ORDER: O R D E R;
|
ORDER: O R D E R;
|
||||||
OUTER: O U T E R;
|
OUTER: O U T E R;
|
||||||
OUTFILE: O U T F I L E;
|
OUTFILE: O U T F I L E;
|
||||||
|
OVER: O V E R;
|
||||||
PARTITION: P A R T I T I O N;
|
PARTITION: P A R T I T I O N;
|
||||||
POPULATE: P O P U L A T E;
|
POPULATE: P O P U L A T E;
|
||||||
|
PRECEDING: P R E C E D I N G;
|
||||||
PREWHERE: P R E W H E R E;
|
PREWHERE: P R E W H E R E;
|
||||||
PRIMARY: P R I M A R Y;
|
PRIMARY: P R I M A R Y;
|
||||||
PROJECTION: P R O J E C T I O N;
|
PROJECTION: P R O J E C T I O N;
|
||||||
@ -140,6 +144,8 @@ REPLICA: R E P L I C A;
|
|||||||
REPLICATED: R E P L I C A T E D;
|
REPLICATED: R E P L I C A T E D;
|
||||||
RIGHT: R I G H T;
|
RIGHT: R I G H T;
|
||||||
ROLLUP: R O L L U P;
|
ROLLUP: R O L L U P;
|
||||||
|
ROW: R O W;
|
||||||
|
ROWS: R O W S;
|
||||||
SAMPLE: S A M P L E;
|
SAMPLE: S A M P L E;
|
||||||
SECOND: S E C O N D;
|
SECOND: S E C O N D;
|
||||||
SELECT: S E L E C T;
|
SELECT: S E L E C T;
|
||||||
@ -171,6 +177,7 @@ TRIM: T R I M;
|
|||||||
TRUNCATE: T R U N C A T E;
|
TRUNCATE: T R U N C A T E;
|
||||||
TTL: T T L;
|
TTL: T T L;
|
||||||
TYPE: T Y P E;
|
TYPE: T Y P E;
|
||||||
|
UNBOUNDED: U N B O U N D E D;
|
||||||
UNION: U N I O N;
|
UNION: U N I O N;
|
||||||
UPDATE: U P D A T E;
|
UPDATE: U P D A T E;
|
||||||
USE: U S E;
|
USE: U S E;
|
||||||
@ -183,6 +190,7 @@ WATCH: W A T C H;
|
|||||||
WEEK: W E E K;
|
WEEK: W E E K;
|
||||||
WHEN: W H E N;
|
WHEN: W H E N;
|
||||||
WHERE: W H E R E;
|
WHERE: W H E R E;
|
||||||
|
WINDOW: W I N D O W;
|
||||||
WITH: W I T H;
|
WITH: W I T H;
|
||||||
YEAR: Y E A R | Y Y Y Y;
|
YEAR: Y E A R | Y Y Y Y;
|
||||||
|
|
||||||
|
@ -243,6 +243,7 @@ selectStmt:
|
|||||||
SELECT DISTINCT? topClause? columnExprList
|
SELECT DISTINCT? topClause? columnExprList
|
||||||
fromClause?
|
fromClause?
|
||||||
arrayJoinClause?
|
arrayJoinClause?
|
||||||
|
windowClause?
|
||||||
prewhereClause?
|
prewhereClause?
|
||||||
whereClause?
|
whereClause?
|
||||||
groupByClause? (WITH (CUBE | ROLLUP))? (WITH TOTALS)?
|
groupByClause? (WITH (CUBE | ROLLUP))? (WITH TOTALS)?
|
||||||
@ -257,6 +258,7 @@ withClause: WITH columnExprList;
|
|||||||
topClause: TOP DECIMAL_LITERAL (WITH TIES)?;
|
topClause: TOP DECIMAL_LITERAL (WITH TIES)?;
|
||||||
fromClause: FROM joinExpr;
|
fromClause: FROM joinExpr;
|
||||||
arrayJoinClause: (LEFT | INNER)? ARRAY JOIN columnExprList;
|
arrayJoinClause: (LEFT | INNER)? ARRAY JOIN columnExprList;
|
||||||
|
windowClause: WINDOW identifier AS LPAREN windowExpr RPAREN;
|
||||||
prewhereClause: PREWHERE columnExpr;
|
prewhereClause: PREWHERE columnExpr;
|
||||||
whereClause: WHERE columnExpr;
|
whereClause: WHERE columnExpr;
|
||||||
groupByClause: GROUP BY ((CUBE | ROLLUP) LPAREN columnExprList RPAREN | columnExprList);
|
groupByClause: GROUP BY ((CUBE | ROLLUP) LPAREN columnExprList RPAREN | columnExprList);
|
||||||
@ -298,6 +300,18 @@ ratioExpr: numberLiteral (SLASH numberLiteral)?;
|
|||||||
settingExprList: settingExpr (COMMA settingExpr)*;
|
settingExprList: settingExpr (COMMA settingExpr)*;
|
||||||
settingExpr: identifier EQ_SINGLE literal;
|
settingExpr: identifier EQ_SINGLE literal;
|
||||||
|
|
||||||
|
windowExpr: winPartitionByClause? winOrderByClause? winFrameClause?;
|
||||||
|
winPartitionByClause: PARTITION BY columnExprList;
|
||||||
|
winOrderByClause: ORDER BY orderExprList;
|
||||||
|
winFrameClause: (ROWS | RANGE) winFrameExtend;
|
||||||
|
winFrameExtend
|
||||||
|
: winFrameBound # frameStart
|
||||||
|
| BETWEEN winFrameBound AND winFrameBound # frameBetween
|
||||||
|
;
|
||||||
|
winFrameBound: (CURRENT ROW | UNBOUNDED PRECEDING | UNBOUNDED FOLLOWING | numberLiteral PRECEDING | numberLiteral FOLLOWING);
|
||||||
|
//rangeClause: RANGE LPAREN (MIN identifier MAX identifier | MAX identifier MIN identifier) RPAREN;
|
||||||
|
|
||||||
|
|
||||||
// SET statement
|
// SET statement
|
||||||
|
|
||||||
setStmt: SET settingExprList;
|
setStmt: SET settingExprList;
|
||||||
@ -364,6 +378,8 @@ columnExpr
|
|||||||
| SUBSTRING LPAREN columnExpr FROM columnExpr (FOR columnExpr)? RPAREN # ColumnExprSubstring
|
| SUBSTRING LPAREN columnExpr FROM columnExpr (FOR columnExpr)? RPAREN # ColumnExprSubstring
|
||||||
| TIMESTAMP STRING_LITERAL # ColumnExprTimestamp
|
| TIMESTAMP STRING_LITERAL # ColumnExprTimestamp
|
||||||
| TRIM LPAREN (BOTH | LEADING | TRAILING) STRING_LITERAL FROM columnExpr RPAREN # ColumnExprTrim
|
| TRIM LPAREN (BOTH | LEADING | TRAILING) STRING_LITERAL FROM columnExpr RPAREN # ColumnExprTrim
|
||||||
|
| identifier (LPAREN columnExprList? RPAREN) OVER LPAREN windowExpr RPAREN # ColumnExprWinFunction
|
||||||
|
| identifier (LPAREN columnExprList? RPAREN) OVER identifier # ColumnExprWinFunctionTarget
|
||||||
| identifier (LPAREN columnExprList? RPAREN)? LPAREN DISTINCT? columnArgList? RPAREN # ColumnExprFunction
|
| identifier (LPAREN columnExprList? RPAREN)? LPAREN DISTINCT? columnArgList? RPAREN # ColumnExprFunction
|
||||||
| literal # ColumnExprLiteral
|
| literal # ColumnExprLiteral
|
||||||
|
|
||||||
@ -454,17 +470,17 @@ interval: SECOND | MINUTE | HOUR | DAY | WEEK | MONTH | QUARTER | YEAR;
|
|||||||
keyword
|
keyword
|
||||||
// except NULL_SQL, INF, NAN_SQL
|
// except NULL_SQL, INF, NAN_SQL
|
||||||
: AFTER | ALIAS | ALL | ALTER | AND | ANTI | ANY | ARRAY | AS | ASCENDING | ASOF | AST | ASYNC | ATTACH | BETWEEN | BOTH | BY | CASE
|
: AFTER | ALIAS | ALL | ALTER | AND | ANTI | ANY | ARRAY | AS | ASCENDING | ASOF | AST | ASYNC | ATTACH | BETWEEN | BOTH | BY | CASE
|
||||||
| CAST | CHECK | CLEAR | CLUSTER | CODEC | COLLATE | COLUMN | COMMENT | CONSTRAINT | CREATE | CROSS | CUBE | DATABASE | DATABASES
|
| CAST | CHECK | CLEAR | CLUSTER | CODEC | COLLATE | COLUMN | COMMENT | CONSTRAINT | CREATE | CROSS | CUBE | CURRENT | DATABASE
|
||||||
| DATE | DEDUPLICATE | DEFAULT | DELAY | DELETE | DESCRIBE | DESC | DESCENDING | DETACH | DICTIONARIES | DICTIONARY | DISK | DISTINCT
|
| DATABASES | DATE | DEDUPLICATE | DEFAULT | DELAY | DELETE | DESCRIBE | DESC | DESCENDING | DETACH | DICTIONARIES | DICTIONARY | DISK
|
||||||
| DISTRIBUTED | DROP | ELSE | END | ENGINE | EVENTS | EXISTS | EXPLAIN | EXPRESSION | EXTRACT | FETCHES | FINAL | FIRST | FLUSH | FOR
|
| DISTINCT | DISTRIBUTED | DROP | ELSE | END | ENGINE | EVENTS | EXISTS | EXPLAIN | EXPRESSION | EXTRACT | FETCHES | FINAL | FIRST
|
||||||
| FORMAT | FREEZE | FROM | FULL | FUNCTION | GLOBAL | GRANULARITY | GROUP | HAVING | HIERARCHICAL | ID | IF | ILIKE | IN | INDEX
|
| FLUSH | FOR | FOLLOWING | FOR | FORMAT | FREEZE | FROM | FULL | FUNCTION | GLOBAL | GRANULARITY | GROUP | HAVING | HIERARCHICAL | ID
|
||||||
| INJECTIVE | INNER | INSERT | INTERVAL | INTO | IS | IS_OBJECT_ID | JOIN | JSON_FALSE | JSON_TRUE | KEY | KILL | LAST | LAYOUT
|
| IF | ILIKE | IN | INDEX | INJECTIVE | INNER | INSERT | INTERVAL | INTO | IS | IS_OBJECT_ID | JOIN | JSON_FALSE | JSON_TRUE | KEY
|
||||||
| LEADING | LEFT | LIFETIME | LIKE | LIMIT | LIVE | LOCAL | LOGS | MATERIALIZE | MATERIALIZED | MAX | MERGES | MIN | MODIFY | MOVE
|
| KILL | LAST | LAYOUT | LEADING | LEFT | LIFETIME | LIKE | LIMIT | LIVE | LOCAL | LOGS | MATERIALIZE | MATERIALIZED | MAX | MERGES
|
||||||
| MUTATION | NO | NOT | NULLS | OFFSET | ON | OPTIMIZE | OR | ORDER | OUTER | OUTFILE | PARTITION | POPULATE | PREWHERE | PRIMARY
|
| MIN | MODIFY | MOVE | MUTATION | NO | NOT | NULLS | OFFSET | ON | OPTIMIZE | OR | ORDER | OUTER | OUTFILE | OVER | PARTITION
|
||||||
| RANGE | RELOAD | REMOVE | RENAME | REPLACE | REPLICA | REPLICATED | RIGHT | ROLLUP | SAMPLE | SELECT | SEMI | SENDS | SET | SETTINGS
|
| POPULATE | PRECEDING | PREWHERE | PRIMARY | RANGE | RELOAD | REMOVE | RENAME | REPLACE | REPLICA | REPLICATED | RIGHT | ROLLUP | ROW
|
||||||
| SHOW | SOURCE | START | STOP | SUBSTRING | SYNC | SYNTAX | SYSTEM | TABLE | TABLES | TEMPORARY | TEST | THEN | TIES | TIMEOUT
|
| ROWS | SAMPLE | SELECT | SEMI | SENDS | SET | SETTINGS | SHOW | SOURCE | START | STOP | SUBSTRING | SYNC | SYNTAX | SYSTEM | TABLE
|
||||||
| TIMESTAMP | TOTALS | TRAILING | TRIM | TRUNCATE | TO | TOP | TTL | TYPE | UNION | UPDATE | USE | USING | UUID | VALUES | VIEW
|
| TABLES | TEMPORARY | TEST | THEN | TIES | TIMEOUT | TIMESTAMP | TOTALS | TRAILING | TRIM | TRUNCATE | TO | TOP | TTL | TYPE
|
||||||
| VOLUME | WATCH | WHEN | WHERE | WITH
|
| UNBOUNDED | UNION | UPDATE | USE | USING | UUID | VALUES | VIEW | VOLUME | WATCH | WHEN | WHERE | WINDOW | WITH
|
||||||
;
|
;
|
||||||
keywordForAlias
|
keywordForAlias
|
||||||
: DATE | FIRST | ID | KEY
|
: DATE | FIRST | ID | KEY
|
||||||
|
Loading…
Reference in New Issue
Block a user