This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new bbaa63bbc13 Add maintenance commands for table model
bbaa63bbc13 is described below
commit bbaa63bbc13ed495e364c4b27ff14a54d938d15a
Author: shuwenwei <[email protected]>
AuthorDate: Fri Feb 7 19:45:25 2025 +0800
Add maintenance commands for table model
---
.../it/db/it/IoTDBLoadConfigurationTableIT.java | 85 +++++++++++++++++++
.../it/db/it/IoTDBSetSystemStatusTableIT.java | 95 ++++++++++++++++++++++
.../iotdb/db/queryengine/plan/Coordinator.java | 4 +
.../execution/config/TableConfigTaskVisitor.java | 20 +++++
.../plan/relational/sql/ast/AstVisitor.java | 8 ++
.../plan/relational/sql/ast/LoadConfiguration.java | 34 ++++++++
.../plan/relational/sql/ast/SetSystemStatus.java | 34 ++++++++
.../plan/relational/sql/parser/AstBuilder.java | 29 ++++++-
8 files changed, 305 insertions(+), 4 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBLoadConfigurationTableIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBLoadConfigurationTableIT.java
new file mode 100644
index 00000000000..53e8bc9487e
--- /dev/null
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBLoadConfigurationTableIT.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.relational.it.db.it;
+
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.TableClusterIT;
+import org.apache.iotdb.itbase.category.TableLocalStandaloneIT;
+import org.apache.iotdb.itbase.env.BaseEnv;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.channels.FileChannel;
+import java.nio.file.StandardOpenOption;
+import java.sql.Connection;
+import java.sql.Statement;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({TableLocalStandaloneIT.class, TableClusterIT.class})
+public class IoTDBLoadConfigurationTableIT {
+ @BeforeClass
+ public static void setUp() throws Exception {
+ EnvFactory.getEnv().initClusterEnvironment();
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ EnvFactory.getEnv().cleanClusterEnvironment();
+ }
+
+ @Test
+ public void loadConfiguration() throws IOException {
+ DataNodeWrapper dataNodeWrapper =
EnvFactory.getEnv().getDataNodeWrapper(0);
+ String confPath =
+ dataNodeWrapper.getNodePath()
+ + File.separator
+ + "conf"
+ + File.separator
+ + "iotdb-system.properties";
+ long length = new File(confPath).length();
+ try (FileWriter fileWriter = new FileWriter(confPath, true)) {
+ fileWriter.write(System.lineSeparator());
+ fileWriter.write("target_compaction_file_size=t");
+ }
+
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+ statement.execute("LOAD CONFIGURATION");
+ Assert.fail();
+ } catch (Exception e) {
+ Assert.assertTrue(e.getMessage().contains("NumberFormatException"));
+ } finally {
+ try (FileChannel fileChannel =
+ FileChannel.open(new File(confPath).toPath(),
StandardOpenOption.WRITE)) {
+ fileChannel.truncate(length);
+ }
+ }
+ }
+}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBSetSystemStatusTableIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBSetSystemStatusTableIT.java
new file mode 100644
index 00000000000..9ad7db2b644
--- /dev/null
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBSetSystemStatusTableIT.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.relational.it.db.it;
+
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.TableClusterIT;
+import org.apache.iotdb.itbase.category.TableLocalStandaloneIT;
+import org.apache.iotdb.itbase.env.BaseEnv;
+
+import org.awaitility.Awaitility;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.concurrent.TimeUnit;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({TableLocalStandaloneIT.class, TableClusterIT.class})
+public class IoTDBSetSystemStatusTableIT {
+ @BeforeClass
+ public static void setUp() throws Exception {
+ EnvFactory.getEnv().initClusterEnvironment();
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ EnvFactory.getEnv().cleanClusterEnvironment();
+ }
+
+ @Test
+ public void setSystemStatus() {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+ statement.execute("SET SYSTEM TO READONLY ON CLUSTER");
+ Awaitility.await()
+ .atMost(10, TimeUnit.SECONDS)
+ .pollDelay(1, TimeUnit.SECONDS)
+ .until(
+ () -> {
+ ResultSet resultSet = statement.executeQuery("SHOW DATANODES");
+ int num = 0;
+ while (resultSet.next()) {
+ String status = resultSet.getString("Status");
+ if (status.equals("ReadOnly")) {
+ num++;
+ }
+ }
+ return num ==
EnvFactory.getEnv().getDataNodeWrapperList().size();
+ });
+
+ statement.execute("SET SYSTEM TO RUNNING ON CLUSTER");
+ Awaitility.await()
+ .atMost(10, TimeUnit.SECONDS)
+ .pollDelay(1, TimeUnit.SECONDS)
+ .until(
+ () -> {
+ ResultSet resultSet = statement.executeQuery("SHOW DATANODES");
+ int num = 0;
+ while (resultSet.next()) {
+ String status = resultSet.getString("Status");
+ if (status.equals("Running")) {
+ num++;
+ }
+ }
+ return num ==
EnvFactory.getEnv().getDataNodeWrapperList().size();
+ });
+ } catch (Exception e) {
+ Assert.fail(e.getMessage());
+ }
+ }
+}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java
index 3ab76899366..851fb33efbd 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java
@@ -73,6 +73,7 @@ import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.DropTable;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ExtendRegion;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Flush;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.KillQuery;
+import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.LoadConfiguration;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.MigrateRegion;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.PipeStatement;
import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ReconstructRegion;
@@ -81,6 +82,7 @@ import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.RemoveDataNode;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.RemoveRegion;
import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SetConfiguration;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SetProperties;
+import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SetSystemStatus;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowAINodes;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCluster;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowClusterId;
@@ -411,6 +413,8 @@ public class Coordinator {
|| statement instanceof Flush
|| statement instanceof ClearCache
|| statement instanceof SetConfiguration
+ || statement instanceof LoadConfiguration
+ || statement instanceof SetSystemStatus
|| statement instanceof StartRepairData
|| statement instanceof StopRepairData
|| statement instanceof PipeStatement
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
index 221b0255ea8..9968142665a 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
@@ -77,7 +77,9 @@ import
org.apache.iotdb.db.queryengine.plan.execution.config.session.ShowCurrent
import
org.apache.iotdb.db.queryengine.plan.execution.config.session.ShowVersionTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.sys.FlushTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.sys.KillQueryTask;
+import
org.apache.iotdb.db.queryengine.plan.execution.config.sys.LoadConfigurationTask;
import
org.apache.iotdb.db.queryengine.plan.execution.config.sys.SetConfigurationTask;
+import
org.apache.iotdb.db.queryengine.plan.execution.config.sys.SetSystemStatusTask;
import
org.apache.iotdb.db.queryengine.plan.execution.config.sys.StartRepairDataTask;
import
org.apache.iotdb.db.queryengine.plan.execution.config.sys.StopRepairDataTask;
import
org.apache.iotdb.db.queryengine.plan.execution.config.sys.pipe.AlterPipeTask;
@@ -124,6 +126,7 @@ import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ExtendRegion;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Flush;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.KillQuery;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Literal;
+import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.LoadConfiguration;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.LongLiteral;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.MigrateRegion;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Node;
@@ -137,6 +140,7 @@ import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.RenameColumn;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.RenameTable;
import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SetConfiguration;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SetProperties;
+import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SetSystemStatus;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowAINodes;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCluster;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowClusterId;
@@ -168,7 +172,9 @@ import
org.apache.iotdb.db.queryengine.plan.statement.metadata.RemoveDataNodeSta
import
org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowClusterStatement;
import
org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowRegionStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.FlushStatement;
+import
org.apache.iotdb.db.queryengine.plan.statement.sys.LoadConfigurationStatement;
import
org.apache.iotdb.db.queryengine.plan.statement.sys.SetConfigurationStatement;
+import
org.apache.iotdb.db.queryengine.plan.statement.sys.SetSystemStatusStatement;
import
org.apache.iotdb.db.queryengine.plan.statement.sys.StartRepairDataStatement;
import
org.apache.iotdb.db.queryengine.plan.statement.sys.StopRepairDataStatement;
import org.apache.iotdb.db.schemaengine.table.InformationSchemaUtils;
@@ -738,6 +744,20 @@ public class TableConfigTaskVisitor extends
AstVisitor<IConfigTask, MPPQueryCont
return new StopRepairDataTask(((StopRepairDataStatement)
node.getInnerTreeStatement()));
}
+ @Override
+ protected IConfigTask visitLoadConfiguration(LoadConfiguration node,
MPPQueryContext context) {
+ context.setQueryType(QueryType.WRITE);
+
accessControl.checkUserHasMaintainPrivilege(context.getSession().getUserName());
+ return new LoadConfigurationTask(((LoadConfigurationStatement)
node.getInnerTreeStatement()));
+ }
+
+ @Override
+ protected IConfigTask visitSetSystemStatus(SetSystemStatus node,
MPPQueryContext context) {
+ context.setQueryType(QueryType.WRITE);
+
accessControl.checkUserHasMaintainPrivilege(context.getSession().getUserName());
+ return new SetSystemStatusTask(((SetSystemStatusStatement)
node.getInnerTreeStatement()));
+ }
+
private Optional<String> parseStringFromLiteralIfBinary(final Object value) {
return value instanceof Literal && ((Literal) value).getTsValue()
instanceof Binary
? Optional.of(
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/AstVisitor.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/AstVisitor.java
index a5fa1f155fa..af0a9d8bae6 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/AstVisitor.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/AstVisitor.java
@@ -433,6 +433,14 @@ public abstract class AstVisitor<R, C> {
return visitStatement(node, context);
}
+ protected R visitLoadConfiguration(LoadConfiguration node, C context) {
+ return visitStatement(node, context);
+ }
+
+ protected R visitSetSystemStatus(SetSystemStatus node, C context) {
+ return visitStatement(node, context);
+ }
+
protected R visitInsertRow(InsertRow node, C context) {
return visitStatement(node, context);
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/LoadConfiguration.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/LoadConfiguration.java
new file mode 100644
index 00000000000..b67ed2b3acf
--- /dev/null
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/LoadConfiguration.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.queryengine.plan.relational.sql.ast;
+
+import org.apache.iotdb.db.queryengine.common.MPPQueryContext;
+import org.apache.iotdb.db.queryengine.plan.statement.Statement;
+
+public class LoadConfiguration extends WrappedStatement {
+ public LoadConfiguration(Statement innerTreeStatement, MPPQueryContext
context) {
+ super(innerTreeStatement, context);
+ }
+
+ @Override
+ public <R, C> R accept(AstVisitor<R, C> visitor, C context) {
+ return visitor.visitLoadConfiguration(this, context);
+ }
+}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/SetSystemStatus.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/SetSystemStatus.java
new file mode 100644
index 00000000000..c767b67c96f
--- /dev/null
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/SetSystemStatus.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.queryengine.plan.relational.sql.ast;
+
+import org.apache.iotdb.db.queryengine.common.MPPQueryContext;
+import org.apache.iotdb.db.queryengine.plan.statement.Statement;
+
+public class SetSystemStatus extends WrappedStatement {
+ public SetSystemStatus(Statement innerTreeStatement, MPPQueryContext
context) {
+ super(innerTreeStatement, context);
+ }
+
+ @Override
+ public <R, C> R accept(AstVisitor<R, C> visitor, C context) {
+ return visitor.visitSetSystemStatus(this, context);
+ }
+}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
index c1802199e85..5a5c2dea4a7 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
@@ -21,6 +21,7 @@ package
org.apache.iotdb.db.queryengine.plan.relational.sql.parser;
import org.apache.iotdb.common.rpc.thrift.TConsensusGroupType;
import org.apache.iotdb.commons.auth.entity.PrivilegeType;
+import org.apache.iotdb.commons.cluster.NodeStatus;
import org.apache.iotdb.commons.exception.IllegalPathException;
import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.schema.cache.CacheClearOptions;
@@ -106,6 +107,7 @@ import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.KillQuery;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.LikePredicate;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Limit;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Literal;
+import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.LoadConfiguration;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.LoadTsFile;
import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.LogicalExpression;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.LongLiteral;
@@ -139,6 +141,7 @@ import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Select;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SelectItem;
import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SetConfiguration;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SetProperties;
+import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SetSystemStatus;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowAINodes;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCluster;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowClusterId;
@@ -191,7 +194,9 @@ import
org.apache.iotdb.db.queryengine.plan.statement.StatementType;
import org.apache.iotdb.db.queryengine.plan.statement.crud.InsertRowStatement;
import org.apache.iotdb.db.queryengine.plan.statement.crud.InsertRowsStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.FlushStatement;
+import
org.apache.iotdb.db.queryengine.plan.statement.sys.LoadConfigurationStatement;
import
org.apache.iotdb.db.queryengine.plan.statement.sys.SetConfigurationStatement;
+import
org.apache.iotdb.db.queryengine.plan.statement.sys.SetSystemStatusStatement;
import
org.apache.iotdb.db.queryengine.plan.statement.sys.StartRepairDataStatement;
import
org.apache.iotdb.db.queryengine.plan.statement.sys.StopRepairDataStatement;
import org.apache.iotdb.db.relational.grammar.sql.RelationalSqlBaseVisitor;
@@ -1230,7 +1235,17 @@ public class AstBuilder extends
RelationalSqlBaseVisitor<Node> {
@Override
public Node visitSetSystemStatusStatement(
RelationalSqlParser.SetSystemStatusStatementContext ctx) {
- return super.visitSetSystemStatusStatement(ctx);
+ SetSystemStatusStatement setSystemStatusStatement = new
SetSystemStatusStatement();
+ setSystemStatusStatement.setOnCluster(
+ ctx.localOrClusterMode() == null || ctx.localOrClusterMode().LOCAL()
== null);
+ if (ctx.RUNNING() != null) {
+ setSystemStatusStatement.setStatus(NodeStatus.Running);
+ } else if (ctx.READONLY() != null) {
+ setSystemStatusStatement.setStatus(NodeStatus.ReadOnly);
+ } else {
+ throw new SemanticException("Unknown system status in set system
command.");
+ }
+ return new SetSystemStatus(setSystemStatusStatement, null);
}
@Override
@@ -1308,7 +1323,11 @@ public class AstBuilder extends
RelationalSqlBaseVisitor<Node> {
@Override
public Node visitLoadConfigurationStatement(
RelationalSqlParser.LoadConfigurationStatementContext ctx) {
- return super.visitLoadConfigurationStatement(ctx);
+ LoadConfigurationStatement loadConfigurationStatement =
+ new LoadConfigurationStatement(StatementType.LOAD_CONFIGURATION);
+ loadConfigurationStatement.setOnCluster(
+ ctx.localOrClusterMode() == null || ctx.localOrClusterMode().LOCAL()
== null);
+ return new LoadConfiguration(loadConfigurationStatement, null);
}
@Override
@@ -1343,7 +1362,8 @@ public class AstBuilder extends
RelationalSqlBaseVisitor<Node> {
RelationalSqlParser.StartRepairDataStatementContext ctx) {
StartRepairDataStatement startRepairDataStatement =
new StartRepairDataStatement(StatementType.START_REPAIR_DATA);
- startRepairDataStatement.setOnCluster(ctx.localOrClusterMode().LOCAL() ==
null);
+ startRepairDataStatement.setOnCluster(
+ ctx.localOrClusterMode() == null || ctx.localOrClusterMode().LOCAL()
== null);
return new StartRepairData(startRepairDataStatement, null);
}
@@ -1351,7 +1371,8 @@ public class AstBuilder extends
RelationalSqlBaseVisitor<Node> {
public Node
visitStopRepairDataStatement(RelationalSqlParser.StopRepairDataStatementContext
ctx) {
StopRepairDataStatement stopRepairDataStatement =
new StopRepairDataStatement(StatementType.STOP_REPAIR_DATA);
- stopRepairDataStatement.setOnCluster(ctx.localOrClusterMode().LOCAL() ==
null);
+ stopRepairDataStatement.setOnCluster(
+ ctx.localOrClusterMode() == null || ctx.localOrClusterMode().LOCAL()
== null);
return new StopRepairData(stopRepairDataStatement, null);
}