From e28327bacc3a9760b2cea29c8aab85a3eb6dac6c Mon Sep 17 00:00:00 2001 From: Grace Cai Date: Wed, 28 Aug 2024 16:24:18 +0800 Subject: [PATCH] SELECT: Update EBNF for partitioning (#18464) --- sql-statements/sql-statement-select.md | 33 ++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 1b3be6aa4218..4502a6dfbf25 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -31,7 +31,27 @@ SelectStmtOpts ::= SelectStmtStraightJoin TableRefsClause ::= - TableRef AsOfClause? ( ',' TableRef AsOfClause? )* + TableRef ( ',' TableRef )* + +TableRef ::= + TableFactor +| JoinTable + +TableFactor ::= + TableName ( "PARTITION" "(" Identifier ("," Identifier)* ")" )? ("AS" TableAlias)? AsOfClause? TableSample? + +JoinTable ::= + TableRef + ( + ("INNER" | "CROSS")? "JOIN" TableRef JoinClause? + | "STRAIGHT_JOIN" TableRef "ON" Expression + | ("LEFT" | "RIGHT") "OUTER"? "JOIN" TableRef JoinClause + | "NATURAL" ("LEFT" | "RIGHT") "OUTER"? "JOIN" TableFactor + ) + +JoinClause ::= + ("ON" Expression + | "USING" "(" ColumnNameList ")" ) AsOfClause ::= 'AS' 'OF' 'TIMESTAMP' Expression @@ -47,10 +67,19 @@ SelectLockOpt ::= TableList ::= TableName ( ',' TableName )* +WhereClause ::= + "WHERE" Expression + +GroupByClause ::= + "GROUP" "BY" Expression + +OrderBy ::= + "ORDER" "BY" Expression + WindowClause ::= "WINDOW" WindowDefinition ("," WindowDefinition)* -TableSampleOpt ::= +TableSample ::= 'TABLESAMPLE' 'REGIONS' '(' ')' ```