LeeGuoPing commented on a change in pull request #15343:
URL: https://github.com/apache/shardingsphere/pull/15343#discussion_r804386190



##########
File path: 
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingTableRulesUsedKeyGeneratorQueryResultSet.java
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.sharding.distsql.handler.query;
+
+import 
org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowShardingTableRulesUsedKeyGeneratorStatement;
+import org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Result set for show sharding table rules used key generator.
+ */
+public final class ShardingTableRulesUsedKeyGeneratorQueryResultSet implements 
DistSQLResultSet {
+    
+    private Iterator<Collection<Object>> data = Collections.emptyIterator();
+    
+    @Override
+    public void init(final ShardingSphereMetaData metaData, final SQLStatement 
sqlStatement) {
+        ShowShardingTableRulesUsedKeyGeneratorStatement statement = 
(ShowShardingTableRulesUsedKeyGeneratorStatement) sqlStatement;
+        List<Collection<Object>> result = new ArrayList<>();
+        Collection<ShardingRuleConfiguration> shardingTableRules = 
metaData.getRuleMetaData().findRuleConfiguration(ShardingRuleConfiguration.class);
+        shardingTableRules.forEach(each -> requireResult(statement, 
metaData.getName(), result, each));
+        data = result.iterator();
+    }
+    
+    private void requireResult(final 
ShowShardingTableRulesUsedKeyGeneratorStatement statement, final String 
schemaName, final List<Collection<Object>> result,
+                               final ShardingRuleConfiguration 
shardingRuleConfiguration) {
+        if (!statement.getKeyGeneratorName().isPresent()) {
+            return;
+        }
+        shardingRuleConfiguration.getTables().forEach(each -> {

Review comment:
       @yx9o Add `autoTables `logic yet , asked @RaigorJiang , not need to 
consider of `DefaultKeyGenerateStrategy` 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]


Reply via email to