RaigorJiang commented on code in PR #20777:
URL: https://github.com/apache/shardingsphere/pull/20777#discussion_r965618851
##########
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java:
##########
@@ -278,24 +278,34 @@ private static void checkTableRule(final String
databaseName, final ShardingRule
}
private static void checkStrategy(final String databaseName, final
ShardingRuleConfiguration currentRuleConfig, final Collection<TableRuleSegment>
rules) throws DistSQLException {
- Collection<String> currentAlgorithms = null == currentRuleConfig ?
Collections.emptySet() : currentRuleConfig.getShardingAlgorithms().keySet();
+ Map<String, AlgorithmConfiguration> currentAlgorithms =
Optional.ofNullable(currentRuleConfig).map(ShardingRuleConfiguration::getShardingAlgorithms).orElse(Collections.emptyMap());
Collection<String> invalidAlgorithms = rules.stream().map(each ->
Arrays.asList(each.getDatabaseStrategySegment(),
each.getTableStrategySegment()))
.flatMap(Collection::stream).filter(Objects::nonNull).filter(each ->
isInvalidStrategy(currentAlgorithms, each))
-
.map(ShardingStrategySegment::getShardingAlgorithmName).collect(Collectors.toList());
+ .map(each ->
Optional.ofNullable(each.getShardingAlgorithmName()).orElse(Optional.ofNullable(each.getAlgorithmSegment()).map(AlgorithmSegment::getName).orElse("unknown")))
Review Comment:
"unknown" is not acceptable information, we should have more discussion,
I'll mark it as draft now.
--
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]