Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -605,10 +605,14 @@ public enum SQLVisitorRule {

ADMIN_SET_PARTITION_VERSION("AdminSetPartitionVersion", SQLStatementType.DAL),

ADMIN_SET_TABLE_STATUS("AdminSetTableStatus", SQLStatementType.DAL),

ADMIN_CLEAN_TRASH("AdminCleanTrash", SQLStatementType.DAL),

ADMIN_REBALANCE_DISK("AdminRebalanceDisk", SQLStatementType.DAL),

ADMIN_CANCEL_REBALANCE_DISK("AdminCancelRebalanceDisk", SQLStatementType.DAL),

ADMIN_REPAIR("AdminRepair", SQLStatementType.DAL),

ADMIN_CANCEL_REPAIR("AdminCancelRepair", SQLStatementType.DAL),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,20 @@ adminSetPartitionVersion
: ADMIN SET TABLE tableName PARTITION VERSION propertiesClause
;

// DORIS ADDED BEGIN
adminSetTableStatus
: ADMIN SET TABLE tableName STATUS propertiesClause
;
// DORIS ADDED END

adminRebalanceDisk
: ADMIN REBALANCE DISK (ON LP_ string_ (COMMA_ string_)* RP_)?
;

adminCancelRebalanceDisk
: ADMIN CANCEL REBALANCE DISK (ON LP_ string_ (COMMA_ string_)* RP_)?
;

adminRepair
: ADMIN REPAIR TABLE tableName (PARTITION LP_ partitionName (COMMA_ partitionName)* RP_)?
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,10 @@ execute
| adminCopyTablet
| adminCheckTablet
| adminSetPartitionVersion
| adminSetTableStatus
| adminCleanTrash
| adminRebalanceDisk
| adminCancelRebalanceDisk
| adminRepair
| adminCancelRepair
| createSqlBlockRule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.PluginPropertyValueContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.AdminCleanTrashContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.AdminRebalanceDiskContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.AdminCancelRebalanceDiskContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.AdminRepairContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.AdminCancelRepairContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.CleanAllProfileContext;
Expand All @@ -160,6 +161,7 @@
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.AdminCopyTabletContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.AdminCheckTabletContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.AdminSetPartitionVersionContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.AdminSetTableStatusContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.CreateSqlBlockRuleContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.CreateWorkloadGroupContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.PropertiesClauseContext;
Expand Down Expand Up @@ -255,7 +257,9 @@
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminCopyTabletStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminCheckTabletStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminSetPartitionVersionStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminSetTableStatusStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminRebalanceDiskStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminCancelRebalanceDiskStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminRepairStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminCancelRepairStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAlterResourceStatement;
Expand Down Expand Up @@ -1328,6 +1332,15 @@ public ASTNode visitAdminRebalanceDisk(final AdminRebalanceDiskContext ctx) {
return result;
}

@Override
public ASTNode visitAdminCancelRebalanceDisk(final AdminCancelRebalanceDiskContext ctx) {
DorisAdminCancelRebalanceDiskStatement result = new DorisAdminCancelRebalanceDiskStatement(getDatabaseType());
if (null != ctx.string_()) {
ctx.string_().forEach(each -> result.getBackends().add(SQLUtils.getExactlyValue(each.getText())));
}
return result;
}

@Override
public ASTNode visitAdminRepair(final AdminRepairContext ctx) {
return new DorisAdminRepairStatement(getDatabaseType(), (SimpleTableSegment) visit(ctx.tableName()),
Expand Down Expand Up @@ -1411,6 +1424,15 @@ public ASTNode visitAdminSetPartitionVersion(final AdminSetPartitionVersionConte
return result;
}

// DORIS ADDED BEGIN
@Override
public ASTNode visitAdminSetTableStatus(final AdminSetTableStatusContext ctx) {
DorisAdminSetTableStatusStatement result = new DorisAdminSetTableStatusStatement(getDatabaseType(), (SimpleTableSegment) visit(ctx.tableName()));
result.setProperties(extractPropertiesSegment(ctx.propertiesClause()));
return result;
}
// DORIS ADDED END

@Override
public ASTNode visitCreateSqlBlockRule(final CreateSqlBlockRuleContext ctx) {
DorisCreateSqlBlockRuleStatement result = new DorisCreateSqlBlockRuleStatement(getDatabaseType());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.shardingsphere.sql.parser.statement.doris.dal;

import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;

import java.util.Collection;
import java.util.LinkedList;

/**
* Admin cancel rebalance disk statement for Doris.
*/
@Getter
public final class DorisAdminCancelRebalanceDiskStatement extends DALStatement {

private final Collection<String> backends = new LinkedList<>();

public DorisAdminCancelRebalanceDiskStatement(final DatabaseType databaseType) {
super(databaseType);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.shardingsphere.sql.parser.statement.doris.dal;

import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.property.PropertiesSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;

/**
* Admin set table status statement for Doris.
*/
@Getter
@Setter
public final class DorisAdminSetTableStatusStatement extends DALStatement {

private final SimpleTableSegment table;

private PropertiesSegment properties;

public DorisAdminSetTableStatusStatement(final DatabaseType databaseType, final SimpleTableSegment table) {
super(databaseType);
this.table = table;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
import org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.UnsetVariableStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminCleanTrashStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminRebalanceDiskStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminCancelRebalanceDiskStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminRepairStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminCancelRepairStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisCleanAllProfileStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisPlanReplayerPlayStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminCopyTabletStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminCheckTabletStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminSetPartitionVersionStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminSetTableStatusStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminSetReplicaStatusStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminSetReplicaVersionStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAlterResourceStatement;
Expand Down Expand Up @@ -67,13 +69,15 @@
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.dialect.doris.type.DorisAdminCleanTrashStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.dialect.doris.type.DorisAdminRebalanceDiskStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.dialect.doris.type.DorisAdminCancelRebalanceDiskStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.dialect.doris.type.DorisAdminRepairStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.dialect.doris.type.DorisAdminCancelRepairStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.dialect.doris.type.DorisCleanAllProfileStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.dialect.doris.type.DorisPlanReplayerPlayStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.dialect.doris.type.DorisAdminCopyTabletStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.dialect.doris.type.DorisAdminCheckTabletStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.dialect.doris.type.DorisAdminSetPartitionVersionStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.dialect.doris.type.DorisAdminSetTableStatusStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.dialect.doris.type.DorisAdminSetReplicaStatusStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.dialect.doris.type.DorisAdminSetReplicaVersionStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.dialect.doris.type.DorisAlterResourceStatementAssert;
Expand Down Expand Up @@ -112,13 +116,15 @@
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisAdminCleanTrashStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisAdminRebalanceDiskStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisAdminCancelRebalanceDiskStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisAdminRepairStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisAdminCancelRepairStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisCleanAllProfileStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisPlanReplayerPlayStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisAdminCopyTabletStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisAdminCheckTabletStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisAdminSetPartitionVersionStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisAdminSetTableStatusStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisAdminSetReplicaStatusStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisAdminSetReplicaVersionStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisAlterResourceStatementTestCase;
Expand Down Expand Up @@ -219,6 +225,8 @@ public static void assertIs(final SQLCaseAssertContext assertContext, final DALS
DorisAdminCheckTabletStatementAssert.assertIs(assertContext, (DorisAdminCheckTabletStatement) actual, (DorisAdminCheckTabletStatementTestCase) expected);
} else if (actual instanceof DorisAdminSetPartitionVersionStatement) {
DorisAdminSetPartitionVersionStatementAssert.assertIs(assertContext, (DorisAdminSetPartitionVersionStatement) actual, (DorisAdminSetPartitionVersionStatementTestCase) expected);
} else if (actual instanceof DorisAdminSetTableStatusStatement) {
DorisAdminSetTableStatusStatementAssert.assertIs(assertContext, (DorisAdminSetTableStatusStatement) actual, (DorisAdminSetTableStatusStatementTestCase) expected);
} else if (actual instanceof DorisShowFileStatement) {
DorisShowFileStatementAssert.assertIs(assertContext, (DorisShowFileStatement) actual, (DorisShowFileStatementTestCase) expected);
} else if (actual instanceof DorisShowEncryptKeysStatement) {
Expand All @@ -227,6 +235,8 @@ public static void assertIs(final SQLCaseAssertContext assertContext, final DALS
DorisAdminCleanTrashStatementAssert.assertIs(assertContext, (DorisAdminCleanTrashStatement) actual, (DorisAdminCleanTrashStatementTestCase) expected);
} else if (actual instanceof DorisAdminRebalanceDiskStatement) {
DorisAdminRebalanceDiskStatementAssert.assertIs(assertContext, (DorisAdminRebalanceDiskStatement) actual, (DorisAdminRebalanceDiskStatementTestCase) expected);
} else if (actual instanceof DorisAdminCancelRebalanceDiskStatement) {
DorisAdminCancelRebalanceDiskStatementAssert.assertIs(assertContext, (DorisAdminCancelRebalanceDiskStatement) actual, (DorisAdminCancelRebalanceDiskStatementTestCase) expected);
} else if (actual instanceof DorisAdminRepairStatement) {
DorisAdminRepairStatementAssert.assertIs(assertContext, (DorisAdminRepairStatement) actual, (DorisAdminRepairStatementTestCase) expected);
} else if (actual instanceof DorisAdminCancelRepairStatement) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.dialect.doris.type;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAdminCancelRebalanceDiskStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisAdminCancelRebalanceDiskStatementTestCase;

import java.util.ArrayList;
import java.util.List;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

/**
* Admin cancel rebalance disk statement assert for Doris.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class DorisAdminCancelRebalanceDiskStatementAssert {

/**
* Assert admin cancel rebalance disk statement is correct with expected parser result.
*
* @param assertContext assert context
* @param actual actual admin cancel rebalance disk statement
* @param expected expected admin cancel rebalance disk statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DorisAdminCancelRebalanceDiskStatement actual, final DorisAdminCancelRebalanceDiskStatementTestCase expected) {
List<String> actualBackends = new ArrayList<>(actual.getBackends());
assertThat(assertContext.getText("backends size does not match: "), actualBackends.size(), is(expected.getBackends().size()));
for (int i = 0; i < actualBackends.size(); i++) {
assertThat(assertContext.getText("backend does not match: "), actualBackends.get(i), is(expected.getBackends().get(i)));
}
}
}
Loading
Loading