Skip to content

Commit 7e488ff

Browse files
author
alpass163
authored
modify the antlr syntax to adapt the calc-point project (#17783)
1 parent 152ee1d commit 7e488ff

4 files changed

Lines changed: 49 additions & 4 deletions

File tree

iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IdentifierParser.g4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ keyWords
180180
| PIPESINKTYPE
181181
| PIPEPLUGIN
182182
| PIPEPLUGINS
183+
| POINT
184+
| POINTS
183185
| POLICY
184186
| PREVIOUS
185187
| PREVIOUSUNTILLAST

iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ ddlStatement
7676
| createLogicalView | dropLogicalView | showLogicalView | renameLogicalView | alterLogicalView
7777
// Table View
7878
| createTableView
79+
// for calculation point
80+
| createCalcPoint | alterCalcPoint | dropCalcPoint | showCalcPoint
7981
;
8082

8183
dmlStatement
@@ -855,6 +857,30 @@ createTableView
855857
AS prefixPath
856858
;
857859

860+
createCalcPoint
861+
: CREATE CALCULATION POINT fullPath
862+
AS expression
863+
STRING_LITERAL
864+
comment?
865+
;
866+
867+
alterCalcPoint
868+
: ALTER CALCULATION POINT fullPath
869+
(AS expression)?
870+
(STRING_LITERAL)?
871+
comment?
872+
(DROP COMMENT)?
873+
;
874+
875+
dropCalcPoint
876+
: DROP CALCULATION POINTS prefixPath
877+
;
878+
879+
showCalcPoint
880+
: SHOW CALCULATION POINTS prefixPath
881+
rowPaginationClause?
882+
;
883+
858884
viewColumnDefinition
859885
: identifier columnCategory=(TAG | TIME | FIELD) comment?
860886
| identifier type (columnCategory=(TAG | TIME | FIELD))? comment?
@@ -1484,6 +1510,7 @@ expression
14841510
| leftExpression=expression operator_or rightExpression=expression
14851511
;
14861512

1513+
14871514
caseWhenThenExpression
14881515
: CASE caseExpression=expression? whenThenExpression+ (ELSE elseExpression=expression)? END
14891516
;

iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ CACHE
137137
: C A C H E
138138
;
139139

140+
CALCULATION
141+
: C A L C U L A T I O N
142+
;
143+
140144
CALL
141145
: C A L L
142146
;
@@ -663,6 +667,14 @@ PIPEPLUGINS
663667
: P I P E P L U G I N S
664668
;
665669

670+
POINT
671+
: P O I N T
672+
;
673+
674+
POINTS
675+
: P O I N T S
676+
;
677+
666678
POLICY
667679
: P O L I C Y
668680
;

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,10 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
361361
public static final String INCORRECT_DATA_TYPE_MSG = "Incorrect Data type";
362362
private ZoneId zoneId;
363363

364+
public boolean isUseWildcard() {
365+
return useWildcard;
366+
}
367+
364368
private boolean useWildcard = false;
365369

366370
private boolean lastLevelUseWildcard = false;
@@ -2390,7 +2394,7 @@ private void parseLoadFileAttributeClause(
23902394
/** Common Parsers. */
23912395

23922396
// IoTDB Objects ========================================================================
2393-
private MeasurementPath parseFullPath(IoTDBSqlParser.FullPathContext ctx) {
2397+
protected MeasurementPath parseFullPath(IoTDBSqlParser.FullPathContext ctx) {
23942398
List<IoTDBSqlParser.NodeNameWithoutWildcardContext> nodeNamesWithoutStar =
23952399
ctx.nodeNameWithoutWildcard();
23962400
String[] path = new String[nodeNamesWithoutStar.size() + 1];
@@ -2421,7 +2425,7 @@ private PartialPath parseAlignedDevice(IoTDBSqlParser.FullPathContext ctx) {
24212425
return new PartialPath(path);
24222426
}
24232427

2424-
private PartialPath parseFullPathInExpression(
2428+
protected PartialPath parseFullPathInExpression(
24252429
IoTDBSqlParser.FullPathInExpressionContext ctx, boolean canUseFullPath) {
24262430
List<IoTDBSqlParser.NodeNameContext> nodeNames = ctx.nodeName();
24272431
int size = nodeNames.size();
@@ -2465,7 +2469,7 @@ private PartialPath parseFullPathInIntoPath(IoTDBSqlParser.FullPathInIntoPathCon
24652469
return new PartialPath(path);
24662470
}
24672471

2468-
private PartialPath parsePrefixPath(IoTDBSqlParser.PrefixPathContext ctx) {
2472+
protected PartialPath parsePrefixPath(IoTDBSqlParser.PrefixPathContext ctx) {
24692473
List<IoTDBSqlParser.NodeNameContext> nodeNames = ctx.nodeName();
24702474
String[] path = new String[nodeNames.size() + 1];
24712475
path[0] = ctx.ROOT().getText();
@@ -3557,7 +3561,7 @@ private String parseConstant(ConstantContext constantContext) {
35573561
}
35583562
}
35593563

3560-
private Expression parseConstantOperand(ConstantContext constantContext) {
3564+
protected Expression parseConstantOperand(ConstantContext constantContext) {
35613565
String text = constantContext.getText();
35623566
if (constantContext.boolean_literal() != null) {
35633567
return new ConstantOperand(TSDataType.BOOLEAN, text);

0 commit comments

Comments
 (0)