Skip to content

Commit

Permalink
add repair data for table model (#14705)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuwenwei authored Jan 15, 2025
1 parent c65b826 commit a11401b
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowTables;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowVariables;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowVersion;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.StartRepairData;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.StopRepairData;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SubscriptionStatement;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Use;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.WrappedInsertStatement;
Expand Down Expand Up @@ -402,6 +404,8 @@ private IQueryExecution createQueryExecutionForTableModel(
|| statement instanceof Flush
|| statement instanceof ClearCache
|| statement instanceof SetConfiguration
|| statement instanceof StartRepairData
|| statement instanceof StopRepairData
|| statement instanceof PipeStatement
|| statement instanceof SubscriptionStatement
|| statement instanceof ShowCurrentSqlDialect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
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.SetConfigurationTask;
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;
import org.apache.iotdb.db.queryengine.plan.execution.config.sys.pipe.CreatePipeTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.sys.pipe.DropPipeTask;
Expand Down Expand Up @@ -141,7 +143,9 @@
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowVariables;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowVersion;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.StartPipe;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.StartRepairData;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.StopPipe;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.StopRepairData;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Use;
import org.apache.iotdb.db.queryengine.plan.relational.sql.rewrite.StatementRewrite;
import org.apache.iotdb.db.queryengine.plan.relational.type.TypeNotFoundException;
Expand All @@ -150,6 +154,8 @@
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.SetConfigurationStatement;
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;

import org.apache.tsfile.common.conf.TSFileConfig;
Expand Down Expand Up @@ -637,6 +643,20 @@ protected IConfigTask visitSetConfiguration(SetConfiguration node, MPPQueryConte
return new SetConfigurationTask(((SetConfigurationStatement) node.getInnerTreeStatement()));
}

@Override
protected IConfigTask visitStartRepairData(StartRepairData node, MPPQueryContext context) {
context.setQueryType(QueryType.WRITE);
accessControl.checkUserHasMaintainPrivilege(context.getSession().getUserName());
return new StartRepairDataTask(((StartRepairDataStatement) node.getInnerTreeStatement()));
}

@Override
protected IConfigTask visitStopRepairData(StopRepairData node, MPPQueryContext context) {
context.setQueryType(QueryType.WRITE);
accessControl.checkUserHasMaintainPrivilege(context.getSession().getUserName());
return new StopRepairDataTask(((StopRepairDataStatement) node.getInnerTreeStatement()));
}

private Optional<String> parseStringFromLiteralIfBinary(final Object value) {
return value instanceof Literal && ((Literal) value).getTsValue() instanceof Binary
? Optional.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,14 @@ protected R visitSetConfiguration(SetConfiguration node, C context) {
return visitStatement(node, context);
}

protected R visitStartRepairData(StartRepairData node, C context) {
return visitStatement(node, context);
}

protected R visitStopRepairData(StopRepairData node, C context) {
return visitStatement(node, context);
}

protected R visitInsertRow(InsertRow node, C context) {
return visitStatement(node, context);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 StartRepairData extends WrappedStatement {
public StartRepairData(Statement innerTreeStatement, MPPQueryContext context) {
super(innerTreeStatement, context);
}

@Override
public <R, C> R accept(AstVisitor<R, C> visitor, C context) {
return visitor.visitStartRepairData(this, context);
}
}
Original file line number Diff line number Diff line change
@@ -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 StopRepairData extends WrappedStatement {
public StopRepairData(Statement innerTreeStatement, MPPQueryContext context) {
super(innerTreeStatement, context);
}

@Override
public <R, C> R accept(AstVisitor<R, C> visitor, C context) {
return visitor.visitStopRepairData(this, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SingleColumn;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SortItem;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.StartPipe;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.StartRepairData;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Statement;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.StopPipe;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.StopRepairData;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.StringLiteral;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SubqueryExpression;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Table;
Expand All @@ -182,6 +184,8 @@
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.SetConfigurationStatement;
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;
import org.apache.iotdb.db.relational.grammar.sql.RelationalSqlLexer;
import org.apache.iotdb.db.relational.grammar.sql.RelationalSqlParser;
Expand Down Expand Up @@ -1177,11 +1181,6 @@ public Node visitClearCacheStatement(final RelationalSqlParser.ClearCacheStateme
options);
}

@Override
public Node visitRepairDataStatement(RelationalSqlParser.RepairDataStatementContext ctx) {
return super.visitRepairDataStatement(ctx);
}

@Override
public Node visitSetSystemStatusStatement(
RelationalSqlParser.SetSystemStatusStatementContext ctx) {
Expand Down Expand Up @@ -1293,6 +1292,23 @@ public Node visitSetConfigurationStatement(
return new SetConfiguration(setConfigurationStatement, null);
}

@Override
public Node visitStartRepairDataStatement(
RelationalSqlParser.StartRepairDataStatementContext ctx) {
StartRepairDataStatement startRepairDataStatement =
new StartRepairDataStatement(StatementType.START_REPAIR_DATA);
startRepairDataStatement.setOnCluster(ctx.localOrClusterMode().LOCAL() == null);
return new StartRepairData(startRepairDataStatement, null);
}

@Override
public Node visitStopRepairDataStatement(RelationalSqlParser.StopRepairDataStatementContext ctx) {
StopRepairDataStatement stopRepairDataStatement =
new StopRepairDataStatement(StatementType.STOP_REPAIR_DATA);
stopRepairDataStatement.setOnCluster(ctx.localOrClusterMode().LOCAL() == null);
return new StopRepairData(stopRepairDataStatement, null);
}

@Override
public Node visitLocalOrClusterMode(RelationalSqlParser.LocalOrClusterModeContext ctx) {
return super.visitLocalOrClusterMode(ctx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ statement
| showVariablesStatement
| flushStatement
| clearCacheStatement
| repairDataStatement
| startRepairDataStatement
| stopRepairDataStatement
| setSystemStatusStatement
| showVersionStatement
| showQueriesStatement
Expand Down Expand Up @@ -479,10 +480,14 @@ clearCacheStatement
: CLEAR clearCacheOptions? CACHE localOrClusterMode?
;

repairDataStatement
: REPAIR DATA localOrClusterMode?
startRepairDataStatement
: START REPAIR DATA localOrClusterMode?
;

stopRepairDataStatement
: STOP REPAIR DATA localOrClusterMode?
;

setSystemStatusStatement
: SET SYSTEM TO (READONLY | RUNNING) localOrClusterMode?
;
Expand Down

0 comments on commit a11401b

Please sign in to comment.