Skip to content

Commit

Permalink
Fix sonar issue (apache#29894)
Browse files Browse the repository at this point in the history
* Rename DropReadwriteSplittingRuleExecutor

* Keep DistSQLExecutor's test case consistent

* Fix sonar issue
  • Loading branch information
terrymanu authored Jan 29, 2024
1 parent cd9c360 commit d185c20
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ public void postValidate(final ShardingRule shardingRule, final SQLStatementCont

private void checkTableInUsed(final ShardingRule shardingRule, final SQLStatementContext sqlStatementContext, final RouteContext routeContext) {
Collection<String> dropTables = sqlStatementContext.getTablesContext().getTableNames();
Set<String> actualTables = routeContext.getRouteUnits().stream().flatMap(each -> each.getTableMappers().stream().map(RouteMapper::getActualName)).collect(Collectors.toSet());
// TODO check actual tables not be used in multi rules, and remove this check logic
Collection<String> otherRuleActualTables = shardingRule.getTableRules().values().stream().filter(each -> !dropTables.contains(each.getLogicTable()))
.flatMap(each -> each.getActualDataNodes().stream().map(DataNode::getTableName)).collect(Collectors.toCollection(CaseInsensitiveSet::new));
if (otherRuleActualTables.isEmpty()) {
return;
}
// TODO check actual tables not be used in multi rules, and remove this check logic
Set<String> actualTables = routeContext.getRouteUnits().stream().flatMap(each -> each.getTableMappers().stream().map(RouteMapper::getActualName)).collect(Collectors.toSet());
Collection<String> inUsedTables = actualTables.stream().filter(otherRuleActualTables::contains).collect(Collectors.toList());
ShardingSpherePreconditions.checkState(inUsedTables.isEmpty(), () -> new DropInUsedTablesException(inUsedTables));
}
Expand Down

0 comments on commit d185c20

Please sign in to comment.