RaigorJiang commented on code in PR #23093:
URL: https://github.com/apache/shardingsphere/pull/23093#discussion_r1056976137
##########
features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java:
##########
@@ -205,14 +208,17 @@ private static boolean isValidDataNode(final String
dataNodeStr) {
return dataNodeStr.contains(DELIMITER) && 2 ==
Splitter.on(DELIMITER).omitEmptyStrings().splitToList(dataNodeStr).size();
}
- private static void checkTables(final String databaseName, final
Collection<AbstractTableRuleSegment> rules, final ShardingRuleConfiguration
currentRuleConfig, final boolean isCreate) {
+ private static void checkTables(final String databaseName, final
Collection<AbstractTableRuleSegment> rules, final ShardingRuleConfiguration
currentRuleConfig, final boolean isCreate,
+ final boolean ifNotExists) {
Collection<String> requiredTables =
rules.stream().map(AbstractTableRuleSegment::getLogicTable).collect(Collectors.toList());
Collection<String> duplicatedTables = getDuplicate(requiredTables);
ShardingSpherePreconditions.checkState(duplicatedTables.isEmpty(), ()
-> new DuplicateRuleException("sharding", databaseName, duplicatedTables));
Collection<String> currentShardingTables = null == currentRuleConfig ?
Collections.emptyList() : getCurrentShardingTables(currentRuleConfig);
if (isCreate) {
- Collection<String> identical = getIdentical(requiredTables,
currentShardingTables);
- ShardingSpherePreconditions.checkState(identical.isEmpty(), () ->
new DuplicateRuleException("sharding", databaseName, identical));
+ if (!ifNotExists) {
+ Collection<String> identical = getIdentical(requiredTables,
currentShardingTables);
Review Comment:
Does the `identical` means `duplicatedRules`?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]