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 2023/03/14 01:51:58 UTC
[iotdb] 03/11: fix ASTVisitor after modify g4
This is an automated email from the ASF dual-hosted git repository.
hui pushed a commit to branch lmh/MLSQL
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 5861dac24e9be740b0d51b94023af5d2126343af
Author: Minghui Liu <li...@foxmail.com>
AuthorDate: Tue Feb 28 09:47:20 2023 +0800
fix ASTVisitor after modify g4
---
.../iotdb/db/mpp/plan/parser/ASTVisitor.java | 74 ++++++++++------------
1 file changed, 32 insertions(+), 42 deletions(-)
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 08791b8217..774652d22c 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
@@ -165,9 +165,9 @@ import org.apache.iotdb.db.mpp.plan.statement.sys.sync.StartPipeStatement;
import org.apache.iotdb.db.mpp.plan.statement.sys.sync.StopPipeStatement;
import org.apache.iotdb.db.qp.sql.IoTDBSqlParser;
import org.apache.iotdb.db.qp.sql.IoTDBSqlParser.ConstantContext;
+import org.apache.iotdb.db.qp.sql.IoTDBSqlParser.CountDatabasesContext;
import org.apache.iotdb.db.qp.sql.IoTDBSqlParser.CountDevicesContext;
import org.apache.iotdb.db.qp.sql.IoTDBSqlParser.CountNodesContext;
-import org.apache.iotdb.db.qp.sql.IoTDBSqlParser.CountStorageGroupContext;
import org.apache.iotdb.db.qp.sql.IoTDBSqlParser.CountTimeseriesContext;
import org.apache.iotdb.db.qp.sql.IoTDBSqlParser.CreateFunctionContext;
import org.apache.iotdb.db.qp.sql.IoTDBSqlParser.DropFunctionContext;
@@ -526,10 +526,10 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
}
}
- // Delete Timeseries ======================================================================
+ // Drop Timeseries ======================================================================
@Override
- public Statement visitDeleteTimeseries(IoTDBSqlParser.DeleteTimeseriesContext ctx) {
+ public Statement visitDropTimeseries(IoTDBSqlParser.DropTimeseriesContext ctx) {
DeleteTimeSeriesStatement deleteTimeSeriesStatement = new DeleteTimeSeriesStatement();
List<PartialPath> partialPaths = new ArrayList<>();
for (IoTDBSqlParser.PrefixPathContext prefixPathContext : ctx.prefixPath()) {
@@ -601,21 +601,21 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
// SHOW DATABASES
@Override
- public Statement visitShowStorageGroup(IoTDBSqlParser.ShowStorageGroupContext ctx) {
- ShowStorageGroupStatement showStorageGroupStatement;
+ public Statement visitShowDatabases(IoTDBSqlParser.ShowDatabasesContext ctx) {
+ ShowStorageGroupStatement showDatabasesStatement;
// Parse prefixPath
if (ctx.prefixPath() != null) {
- showStorageGroupStatement = new ShowStorageGroupStatement(parsePrefixPath(ctx.prefixPath()));
+ showDatabasesStatement = new ShowStorageGroupStatement(parsePrefixPath(ctx.prefixPath()));
} else {
- showStorageGroupStatement =
+ showDatabasesStatement =
new ShowStorageGroupStatement(new PartialPath(SqlConstant.getSingleRootArray()));
}
// Is detailed
- showStorageGroupStatement.setDetailed(ctx.DETAILS() != null);
+ showDatabasesStatement.setDetailed(ctx.DETAILS() != null);
- return showStorageGroupStatement;
+ return showDatabasesStatement;
}
// Show Devices ========================================================================
@@ -694,7 +694,7 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
// Count StorageGroup ========================================================================
@Override
- public Statement visitCountStorageGroup(CountStorageGroupContext ctx) {
+ public Statement visitCountDatabases(CountDatabasesContext ctx) {
PartialPath path;
if (ctx.prefixPath() != null) {
path = parsePrefixPath(ctx.prefixPath());
@@ -1586,15 +1586,6 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
return new PartialPath(path);
}
- private PartialPath parseSuffixPath(IoTDBSqlParser.SuffixPathContext ctx) {
- List<IoTDBSqlParser.NodeNameContext> nodeNames = ctx.nodeName();
- String[] path = new String[nodeNames.size()];
- for (int i = 0; i < nodeNames.size(); i++) {
- path[i] = parseNodeName(nodeNames.get(i));
- }
- return new PartialPath(path);
- }
-
private PartialPath convertConstantToPath(String src) throws IllegalPathException {
return new PartialPath(src);
}
@@ -2002,49 +1993,48 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
// Create database
@Override
- public Statement visitCreateStorageGroup(IoTDBSqlParser.CreateStorageGroupContext ctx) {
+ public Statement visitCreateDatabase(IoTDBSqlParser.CreateDatabaseContext ctx) {
DatabaseSchemaStatement databaseSchemaStatement =
new DatabaseSchemaStatement(DatabaseSchemaStatement.DatabaseSchemaStatementType.CREATE);
PartialPath path = parsePrefixPath(ctx.prefixPath());
databaseSchemaStatement.setStorageGroupPath(path);
- if (ctx.storageGroupAttributesClause() != null) {
- parseStorageGroupAttributesClause(
- databaseSchemaStatement, ctx.storageGroupAttributesClause());
+ if (ctx.databaseAttributesClause() != null) {
+ parseDatabaseAttributesClause(databaseSchemaStatement, ctx.databaseAttributesClause());
}
return databaseSchemaStatement;
}
@Override
- public Statement visitAlterStorageGroup(IoTDBSqlParser.AlterStorageGroupContext ctx) {
+ public Statement visitAlterDatabase(IoTDBSqlParser.AlterDatabaseContext ctx) {
DatabaseSchemaStatement databaseSchemaStatement =
new DatabaseSchemaStatement(DatabaseSchemaStatement.DatabaseSchemaStatementType.ALTER);
PartialPath path = parsePrefixPath(ctx.prefixPath());
databaseSchemaStatement.setStorageGroupPath(path);
- parseStorageGroupAttributesClause(databaseSchemaStatement, ctx.storageGroupAttributesClause());
+ parseDatabaseAttributesClause(databaseSchemaStatement, ctx.databaseAttributesClause());
return databaseSchemaStatement;
}
- private void parseStorageGroupAttributesClause(
+ private void parseDatabaseAttributesClause(
DatabaseSchemaStatement databaseSchemaStatement,
- IoTDBSqlParser.StorageGroupAttributesClauseContext ctx) {
- for (IoTDBSqlParser.StorageGroupAttributeClauseContext attribute :
- ctx.storageGroupAttributeClause()) {
- if (attribute.TTL() != null) {
+ IoTDBSqlParser.DatabaseAttributesClauseContext ctx) {
+ for (IoTDBSqlParser.DatabaseAttributeClauseContext attribute : ctx.databaseAttributeClause()) {
+ IoTDBSqlParser.DatabaseAttributeKeyContext attributeKey = attribute.databaseAttributeKey();
+ if (attributeKey.TTL() != null) {
long ttl = Long.parseLong(attribute.INTEGER_LITERAL().getText());
databaseSchemaStatement.setTTL(ttl);
- } else if (attribute.SCHEMA_REPLICATION_FACTOR() != null) {
+ } else if (attributeKey.SCHEMA_REPLICATION_FACTOR() != null) {
int schemaReplicationFactor = Integer.parseInt(attribute.INTEGER_LITERAL().getText());
databaseSchemaStatement.setSchemaReplicationFactor(schemaReplicationFactor);
- } else if (attribute.DATA_REPLICATION_FACTOR() != null) {
+ } else if (attributeKey.DATA_REPLICATION_FACTOR() != null) {
int dataReplicationFactor = Integer.parseInt(attribute.INTEGER_LITERAL().getText());
databaseSchemaStatement.setDataReplicationFactor(dataReplicationFactor);
- } else if (attribute.TIME_PARTITION_INTERVAL() != null) {
+ } else if (attributeKey.TIME_PARTITION_INTERVAL() != null) {
long timePartitionInterval = Long.parseLong(attribute.INTEGER_LITERAL().getText());
databaseSchemaStatement.setTimePartitionInterval(timePartitionInterval);
- } else if (attribute.SCHEMA_REGION_GROUP_NUM() != null) {
+ } else if (attributeKey.SCHEMA_REGION_GROUP_NUM() != null) {
int schemaRegionGroupNum = Integer.parseInt(attribute.INTEGER_LITERAL().getText());
databaseSchemaStatement.setSchemaRegionGroupNum(schemaRegionGroupNum);
- } else if (attribute.DATA_REGION_GROUP_NUM() != null) {
+ } else if (attributeKey.DATA_REGION_GROUP_NUM() != null) {
int dataRegionGroupNum = Integer.parseInt(attribute.INTEGER_LITERAL().getText());
databaseSchemaStatement.setDataRegionGroupNum(dataRegionGroupNum);
}
@@ -2101,15 +2091,15 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
}
@Override
- public Statement visitDeleteStorageGroup(IoTDBSqlParser.DeleteStorageGroupContext ctx) {
- DeleteStorageGroupStatement deleteStorageGroupStatement = new DeleteStorageGroupStatement();
+ public Statement visitDropDatabase(IoTDBSqlParser.DropDatabaseContext ctx) {
+ DeleteStorageGroupStatement dropDatabaseStatement = new DeleteStorageGroupStatement();
List<IoTDBSqlParser.PrefixPathContext> prefixPathContexts = ctx.prefixPath();
List<String> paths = new ArrayList<>();
for (IoTDBSqlParser.PrefixPathContext prefixPathContext : prefixPathContexts) {
paths.add(parsePrefixPath(prefixPathContext).getFullPath());
}
- deleteStorageGroupStatement.setPrefixPath(paths);
- return deleteStorageGroupStatement;
+ dropDatabaseStatement.setPrefixPath(paths);
+ return dropDatabaseStatement;
}
// Explain ========================================================================
@@ -2722,7 +2712,7 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
// show region
@Override
- public Statement visitShowRegion(IoTDBSqlParser.ShowRegionContext ctx) {
+ public Statement visitShowRegions(IoTDBSqlParser.ShowRegionsContext ctx) {
ShowRegionStatement showRegionStatement = new ShowRegionStatement();
// TODO: Maybe add a show ConfigNode region in the future
if (ctx.DATA() != null) {
@@ -2962,8 +2952,8 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
}
@Override
- public Statement visitDeleteTimeseriesOfSchemaTemplate(
- IoTDBSqlParser.DeleteTimeseriesOfSchemaTemplateContext ctx) {
+ public Statement visitDropTimeseriesOfSchemaTemplate(
+ IoTDBSqlParser.DropTimeseriesOfSchemaTemplateContext ctx) {
DeactivateTemplateStatement statement = new DeactivateTemplateStatement();
if (ctx.templateName != null) {
statement.setTemplateName(parseIdentifier(ctx.templateName.getText()));