menghaoranss commented on a change in pull request #10110:
URL: https://github.com/apache/shardingsphere/pull/10110#discussion_r614720398



##########
File path: 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/test/java/org/apache/shardingsphere/distsql/parser/api/DistSQLStatementParserEngineTest.java
##########
@@ -42,6 +44,12 @@
     
     private static final String RDL_DROP_RESOURCE = "DROP RESOURCE ds_0,ds_1";
     
+    private static final String RDL_CREATE_SHARDING_TABLE_RULE = "CREATE 
SHARDING TABLE RULE t_order (" 
+            + "RESOURCES(ms_group_0,ms_group_1)," 
+            + "SHARDING_COLUMN=order_id," 
+            + "TYPE(NAME=hash_mod,PROPERTIES(\"sharding-count\"=4))," 

Review comment:
       UT has been added for `sharding-count` and other properties.

##########
File path: 
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/converter/ShardingRuleStatementConverter.java
##########
@@ -46,19 +47,35 @@
      * @return YAML sharding rule configuration
      */
     public static YamlShardingRuleConfiguration convert(final 
CreateShardingRuleStatement sqlStatement) {
+        YamlShardingRuleConfiguration result = 
convertTableRuleSegments(sqlStatement.getTables());
+        for (Collection<String> each : sqlStatement.getBindingTables()) {
+            result.getBindingTables().add(Joiner.on(",").join(each));
+        }
+        return result;
+    }
+    
+    /**
+     * Convert create sharding table rule statement context to YAML sharding 
rule configuration.
+     * 
+     * @param sqlStatement create sharding table rule statement
+     * @return YAML sharding rule configuration
+     */
+    public static YamlShardingRuleConfiguration convert(final 
CreateShardingTableRuleStatement sqlStatement) {
+        return convertTableRuleSegments(sqlStatement.getTables());
+    }
+    
+    private static YamlShardingRuleConfiguration 
convertTableRuleSegments(final Collection<TableRuleSegment> tableRuleSegments) {
         YamlShardingRuleConfiguration result = new 
YamlShardingRuleConfiguration();
-        for (TableRuleSegment each : sqlStatement.getTables()) {
+        for (TableRuleSegment each : tableRuleSegments) {
             if (null != each.getTableStrategy()) {
                 
result.getShardingAlgorithms().put(getAlgorithmName(each.getLogicTable(), 
each.getTableStrategy().getAlgorithmName()), 
createAlgorithmConfiguration(each.getTableStrategy()));
                 result.getAutoTables().put(each.getLogicTable(), 
createAutoTableRuleConfiguration(each));
             }
         }
-        for (Collection<String> each : sqlStatement.getBindingTables()) {
-            result.getBindingTables().add(Joiner.on(",").join(each));
-        }
         return result;
     }
     
+    

Review comment:
       deleted




-- 
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:
[email protected]


Reply via email to