You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/01/25 12:11:00 UTC

[GitHub] [shardingsphere] tristaZero commented on a change in pull request #9112: add support alter sharding rule

tristaZero commented on a change in pull request #9112:
URL: https://github.com/apache/shardingsphere/pull/9112#discussion_r563675716



##########
File path: shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/DistSQLVisitor.java
##########
@@ -103,13 +109,61 @@ public ASTNode visitDataSourceDefinition(final DataSourceDefinitionContext ctx)
     
     @Override
     public ASTNode visitCreateShardingRule(final CreateShardingRuleContext ctx) {
-        Collection<TableRuleSegment> tables = new LinkedList<>();
+        CreateShardingRuleStatement result;
+        if (null != ctx.defaultTableStrategy()) {
+            String defaultTableStrategyColumn = null != ctx.defaultTableStrategy().columnName() ? ctx.defaultTableStrategy().columnName().getText() : null;
+            result = new CreateShardingRuleStatement(defaultTableStrategyColumn, (FunctionSegment) visit(ctx.defaultTableStrategy()));
+        } else {
+            result = new CreateShardingRuleStatement(null, null);
+        }
         for (ShardingTableRuleDefinitionContext each : ctx.shardingTableRuleDefinition()) {
-            tables.add((TableRuleSegment) visit(each));
+            result.getTables().add((TableRuleSegment) visit(each));
+        }
+        if (null != ctx.bindingTables()) {
+            for (TableNamesContext each : ctx.bindingTables().tableNames()) {
+                Collection<String> tables = each.IDENTIFIER().stream().map(t -> new IdentifierValue(t.getText()).getValue()).collect(Collectors.toList());
+                result.getBindingTables().add(Joiner.on(",").join(tables));
+            }
         }
-        return new CreateShardingRuleStatement(tables);
+        if (null != ctx.broadcastTables()) {
+            for (TerminalNode each : ctx.broadcastTables().IDENTIFIER()) {
+                result.getBroadcastTables().add(new IdentifierValue(each.getText()).getValue());
+            }
+        }
+        return result;
     }
-
+    
+    @Override
+    public ASTNode visitAlterShardingRule(final AlterShardingRuleContext ctx) {
+        AlterShardingRuleStatement result;
+        if (null != ctx.defaultTableStrategy()) {
+            String defaultTableStrategyColumn = null != ctx.defaultTableStrategy().columnName() ? ctx.defaultTableStrategy().columnName().getText() : null;
+    

Review comment:
       Please remove it.




----------------------------------------------------------------
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:
users@infra.apache.org