This is an automated email from the ASF dual-hosted git repository.

rong pushed a commit to branch iotdb-1022-v2
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 24091226b382570f73df6991ab19c9f2aedb5925
Author: SteveYurongSu <[email protected]>
AuthorDate: Mon May 10 15:40:50 2021 +0800

    antlr grammar for arithmetic operators and nested operators
---
 .../antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4   | 130 ++++-----------------
 1 file changed, 23 insertions(+), 107 deletions(-)

diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4 
b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4
index dd629dd..5d9d1d3 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4
@@ -103,71 +103,35 @@ statement
     | START TRIGGER triggerName=ID #startTrigger
     | STOP TRIGGER triggerName=ID #stopTrigger
     | SHOW TRIGGERS #showTriggers
-    | SELECT topClause? selectElements
-    fromClause
-    whereClause?
-    specialClause? #selectStatement
+    | selectClause fromClause whereClause? specialClause? #selectStatement
     ;
 
-selectElements
-    : aggregationCall (COMMA aggregationCall)* #aggregationElement
-    | tableCall (COMMA tableCall)* #tableElement
-    | lastClause #lastElement
-    | asClause (COMMA asClause)* #asElement
-    | functionAsClause (COMMA functionAsClause)* #functionAsElement
-    ;
-
-aggregationCall
-    : builtInFunctionCall
-    | udfCall
-    ;
-
-tableCall
-    : suffixPath
-    | udfCall
-    | SINGLE_QUOTE_STRING_LITERAL
-    ;
-
-udfCall
-    : udfName=ID LR_BRACKET udfSuffixPaths udfAttribute* RR_BRACKET
-    ;
-
-udfSuffixPaths
-    : suffixPath (COMMA suffixPath)*
-    ;
-
-udfAttribute
-    : COMMA udfAttributeKey=stringLiteral OPERATOR_EQ 
udfAttributeValue=stringLiteral
-    ;
-
-builtInFunctionCall
-    : functionName LR_BRACKET suffixPath RR_BRACKET
-    ;
+selectClause
+   : SELECT (LAST | topClause)? complexOperationAsClause (COMMA 
complexOperationAsClause)*
+   ;
 
-functionName
-    : MIN_TIME
-    | MAX_TIME
-    | MIN_VALUE
-    | MAX_VALUE
-    | COUNT
-    | AVG
-    | FIRST_VALUE
-    | SUM
-    | LAST_VALUE
-    ;
+complexOperationAsClause
+   : complexOperationClause (AS ID)?
+   ;
 
-functionAsClause
-    : builtInFunctionCall (AS ID)?
-    ;
+complexOperationClause
+   : realLiteral
+   | suffixPath
+   | functionClause
+   | '(' complexOperationClause ')'
+   | ('+' | '-') complexOperationClause
+   | complexOperationClause ('*' | '/' | '%') complexOperationClause
+   | complexOperationClause ('+' | '-') complexOperationClause
+   ;
 
-lastClause
-    : LAST suffixPath (COMMA suffixPath)*
-    | LAST asClause (COMMA asClause)*
-    ;
+functionClause
+   : functionName=ID LR_BRACKET complexOperationClause (COMMA 
complexOperationClause)*
+     functionAttribute* RR_BRACKET
+   ;
 
-asClause
-    : suffixPath (AS ID)?
-    ;
+functionAttribute
+   : COMMA functionAttributeKey=stringLiteral OPERATOR_EQ 
functionAttributeValue=stringLiteral
+   ;
 
 alias
     : LR_BRACKET ID RR_BRACKET
@@ -518,14 +482,6 @@ nodeName
     | COUNT
     | NODES
     | LEVEL
-    | MIN_TIME
-    | MAX_TIME
-    | MIN_VALUE
-    | MAX_VALUE
-    | AVG
-    | FIRST_VALUE
-    | SUM
-    | LAST_VALUE
     | LAST
     | DISABLE
     | ALIGN
@@ -629,14 +585,6 @@ nodeNameWithoutStar
     | COUNT
     | NODES
     | LEVEL
-    | MIN_TIME
-    | MAX_TIME
-    | MIN_VALUE
-    | MAX_VALUE
-    | AVG
-    | FIRST_VALUE
-    | SUM
-    | LAST_VALUE
     | LAST
     | DISABLE
     | ALIGN
@@ -1096,38 +1044,6 @@ LEVEL
     : L E V E L
     ;
 
-MIN_TIME
-    : M I N UNDERLINE T I M E
-    ;
-
-MAX_TIME
-    : M A X UNDERLINE T I M E
-    ;
-
-MIN_VALUE
-    : M I N UNDERLINE V A L U E
-    ;
-
-MAX_VALUE
-    : M A X UNDERLINE V A L U E
-    ;
-
-AVG
-    : A V G
-    ;
-
-FIRST_VALUE
-    : F I R S T UNDERLINE V A L U E
-    ;
-
-SUM
-    : S U M
-    ;
-
-LAST_VALUE
-    : L A S T UNDERLINE V A L U E
-    ;
-
 LAST
     : L A S T
     ;

Reply via email to