You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/06/14 08:08:16 UTC
[GitHub] [shardingsphere] xiaoshen11 opened a new pull request #10800: Create DropTableStatementFederateRefresher for issues#10697
xiaoshen11 opened a new pull request #10800:
URL: https://github.com/apache/shardingsphere/pull/10800
Fixes #10697.
Changes proposed in this pull request:
- Create DropTableStatementFederateRefresher
- add DropTableStatementFederateRefresherTest
-
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] xiaoshen11 commented on pull request #10800: Create DropTableStatementFederateRefresher for issues#10697
Posted by GitBox <gi...@apache.org>.
xiaoshen11 commented on pull request #10800:
URL: https://github.com/apache/shardingsphere/pull/10800#issuecomment-864523739
@tristaZero Thanks for your guidance
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] tristaZero merged pull request #10800: Create DropTableStatementFederateRefresher for issues#10697
Posted by GitBox <gi...@apache.org>.
tristaZero merged pull request #10800:
URL: https://github.com/apache/shardingsphere/pull/10800
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] tristaZero commented on a change in pull request #10800: Create DropTableStatementFederateRefresher for issues#10697
Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #10800:
URL: https://github.com/apache/shardingsphere/pull/10800#discussion_r652367108
##########
File path: shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/core/metadata/refresher/type/DropTableStatementFederateRefresher.java
##########
@@ -0,0 +1,44 @@
+/*
+ * 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.infra.optimize.core.metadata.refresher.type;
+
+import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
+import org.apache.shardingsphere.infra.metadata.schema.builder.SchemaBuilderMaterials;
+import org.apache.shardingsphere.infra.metadata.schema.refresher.event.DropTableEvent;
+import org.apache.shardingsphere.infra.optimize.core.metadata.FederateSchemaMetadata;
+import org.apache.shardingsphere.infra.optimize.core.metadata.refresher.FederateRefresher;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropTableStatement;
+
+import java.sql.SQLException;
+import java.util.Collection;
+
+/**
+ * ShardingSphere Federate refresher for drop table statement.
+ */
+public final class DropTableStatementFederateRefresher implements FederateRefresher<DropTableStatement> {
+
+ @Override
+ public void refresh(final FederateSchemaMetadata schema, final Collection<String> routeDataSourceNames, final DropTableStatement sqlStatement, final SchemaBuilderMaterials materials)
+ throws SQLException {
+ sqlStatement.getTables().forEach(each -> schema.remove(each.getTableName().getIdentifier().getValue()));
+ for (SimpleTableSegment each : sqlStatement.getTables()) {
+ ShardingSphereEventBus.getInstance().post(new DropTableEvent(each.getTableName().getIdentifier().getValue()));
Review comment:
Hi it is unnecessary to post the events here. Please remove these codings.
##########
File path: shardingsphere-infra/shardingsphere-infra-optimize/src/test/java/org/apache/shardingsphere/infra/optimize/core/metadata/refresher/DropTableStatementFederateRefresherTest.java
##########
@@ -0,0 +1,100 @@
+package org.apache.shardingsphere.infra.optimize.core.metadata.refresher;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.shardingsphere.infra.metadata.schema.builder.SchemaBuilderMaterials;
+import org.apache.shardingsphere.infra.metadata.schema.model.ColumnMetaData;
+import org.apache.shardingsphere.infra.metadata.schema.model.IndexMetaData;
+import org.apache.shardingsphere.infra.metadata.schema.model.TableMetaData;
+import org.apache.shardingsphere.infra.optimize.core.metadata.FederateSchemaMetadata;
+import org.apache.shardingsphere.infra.optimize.core.metadata.refresher.type.DropTableStatementFederateRefresher;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.TableNameSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropTableStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.ddl.MySQLDropTableStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleDropTableStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.ddl.PostgreSQLDropTableStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.sql92.ddl.SQL92DropTableStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.ddl.SQLServerDropTableStatement;
+import org.junit.Test;
+
+import java.sql.SQLException;
+import java.util.Collections;
+import java.util.Map;
+
+import static org.junit.Assert.assertFalse;
+import static org.mockito.Mockito.mock;
+
+public class DropTableStatementFederateRefresherTest {
Review comment:
Hi it is suggested to be final class.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] tristaZero commented on pull request #10800: Create DropTableStatementFederateRefresher for issues#10697
Posted by GitBox <gi...@apache.org>.
tristaZero commented on pull request #10800:
URL: https://github.com/apache/shardingsphere/pull/10800#issuecomment-862059065
@xiaoshen11 Hi thanks for this PR, please look at the failed CI tests. Besides, some comments still need your attention.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org