You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hu...@apache.org on 2022/10/31 03:15:41 UTC
[iotdb] 02/02: [IOTDB-4527] Support sql does not contains comma
This is an automated email from the ASF dual-hosted git repository.
hui pushed a commit to branch lmh/flexSQL
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 3a63032e7e0db71b198d846f2ea6d057240dd0f9
Author: Minghui Liu <li...@foxmail.com>
AuthorDate: Mon Oct 31 11:15:11 2022 +0800
[IOTDB-4527] Support sql does not contains comma
---
.../org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 | 27 ++++++++++++++--------
.../iotdb/db/mpp/plan/parser/ASTVisitor.java | 13 +++++------
2 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
index cd1d4da136..51cb8f178d 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
@@ -79,7 +79,7 @@ createStorageGroup
;
storageGroupAttributesClause
- : WITH storageGroupAttributeClause (COMMA storageGroupAttributeClause)*
+ : WITH storageGroupAttributeClause (COMMA? storageGroupAttributeClause)*
;
storageGroupAttributeClause
@@ -127,7 +127,12 @@ uri
// Create Trigger
createTrigger
- : CREATE triggerType? TRIGGER triggerName=identifier triggerEventClause ON prefixPath AS className=STRING_LITERAL uriClasue? triggerAttributeClause?
+ : CREATE triggerType? TRIGGER triggerName=identifier
+ triggerEventClause
+ ON prefixPath
+ AS className=STRING_LITERAL
+ uriClasue?
+ triggerAttributeClause?
;
triggerType
@@ -746,13 +751,17 @@ loadTimeseries
// Load TsFile
loadFile
- : LOAD fileName=STRING_LITERAL loadFilesClause?
+ : LOAD fileName=STRING_LITERAL loadFileAttributeClauses?
;
-loadFilesClause
- : SGLEVEL operator_eq INTEGER_LITERAL (loadFilesClause)?
- | VERIFY operator_eq BOOLEAN_LITERAL (loadFilesClause)?
- | ONSUCCESS operator_eq (DELETE|NONE) (loadFilesClause)?
+loadFileAttributeClauses
+ : loadFileAttributeClause (COMMA? loadFileAttributeClause)*
+ ;
+
+loadFileAttributeClause
+ : SGLEVEL operator_eq INTEGER_LITERAL
+ | VERIFY operator_eq BOOLEAN_LITERAL
+ | ONSUCCESS operator_eq (DELETE|NONE)
;
// Remove TsFile
@@ -809,7 +818,7 @@ dropPipe
// attribute clauses
syncAttributeClauses
- : attributePair (COMMA attributePair)*
+ : attributePair (COMMA? attributePair)*
;
@@ -944,7 +953,7 @@ fromClause
attributeClauses
: aliasNodeName? WITH attributeKey operator_eq dataType=attributeValue
- (COMMA attributePair)*
+ (COMMA? attributePair)*
tagClause?
attributeClause?
// Simplified version (supported since v0.13)
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
index 0c5eaf8ad0..22566331c5 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
@@ -1638,8 +1638,10 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
try {
LoadTsFileStatement loadTsFileStatement =
new LoadTsFileStatement(parseStringLiteral(ctx.fileName.getText()));
- if (ctx.loadFilesClause() != null) {
- parseLoadFiles(loadTsFileStatement, ctx.loadFilesClause());
+ if (ctx.loadFileAttributeClauses() != null) {
+ for (IoTDBSqlParser.LoadFileAttributeClauseContext attributeContext :
+ ctx.loadFileAttributeClauses().loadFileAttributeClause())
+ parseLoadFileAttributeClause(loadTsFileStatement, attributeContext);
}
return loadTsFileStatement;
} catch (FileNotFoundException e) {
@@ -1654,8 +1656,8 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
* @param loadTsFileStatement the result statement, setting by clause context
* @param ctx context of property statement
*/
- private void parseLoadFiles(
- LoadTsFileStatement loadTsFileStatement, IoTDBSqlParser.LoadFilesClauseContext ctx) {
+ private void parseLoadFileAttributeClause(
+ LoadTsFileStatement loadTsFileStatement, IoTDBSqlParser.LoadFileAttributeClauseContext ctx) {
if (ctx.ONSUCCESS() != null) {
loadTsFileStatement.setDeleteAfterLoad(ctx.DELETE() != null);
} else if (ctx.SGLEVEL() != null) {
@@ -1668,9 +1670,6 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
"load tsfile format %s error, please input AUTOREGISTER | SGLEVEL | VERIFY.",
ctx.getText()));
}
- if (ctx.loadFilesClause() != null) {
- parseLoadFiles(loadTsFileStatement, ctx.loadFilesClause());
- }
}
/** Common Parsers */