You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/01/08 12:18:09 UTC
[shardingsphere] branch master updated: update sharding distsql syntax doc for keyGenerator definition (#14623)
This is an automated email from the ASF dual-hosted git repository.
zhonghongsheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 744df17 update sharding distsql syntax doc for keyGenerator definition (#14623)
744df17 is described below
commit 744df17a0dae8a0fb2c3aa4dd328b3f79ad37312
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Sat Jan 8 20:17:22 2022 +0800
update sharding distsql syntax doc for keyGenerator definition (#14623)
* update sharding distsql syntax doc for keyGenerator definition
* remove duplicate shardingColumn definition in doc
* update show key generators in rql
---
.../distsql/syntax/rdl/rule-definition/sharding.cn.md | 18 ++++++++++++------
.../distsql/syntax/rdl/rule-definition/sharding.en.md | 18 ++++++++++++------
.../distsql/syntax/rql/rule-query/sharding.cn.md | 2 ++
.../distsql/syntax/rql/rule-query/sharding.en.md | 2 ++
.../src/main/antlr4/imports/sharding/RDLStatement.g4 | 6 +++---
.../parser/core/ShardingDistSQLStatementVisitor.java | 8 ++++----
6 files changed, 35 insertions(+), 19 deletions(-)
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.cn.md
index 27bde2d..cb0e550 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.cn.md
@@ -20,12 +20,18 @@ ALTER DEFAULT SHARDING shardingScope STRATEGY (shardingStrategy)
DROP DEFAULT SHARDING shardingScope STRATEGY;
-CREATE SHARDING ALGORITHM shardingAlgorithmDefinition [, shardingAlgorithmDefinition] ...
+CREATE SHARDING ALGORITHM shardingAlgorithmDefinition [, shardingAlgorithmDefinition] ...
-ALTER SHARDING ALGORITHM shardingAlgorithmDefinition [, shardingAlgorithmDefinition] ...
+ALTER SHARDING ALGORITHM shardingAlgorithmDefinition [, shardingAlgorithmDefinition] ...
DROP SHARDING ALGORITHM algorithmName [, algorithmName] ...
+CREATE SHARDING KEY GENERATOR keyGeneratorDefinition [, keyGeneratorDefinition] ...
+
+ALTER SHARDING KEY GENERATOR keyGeneratorDefinition [, keyGeneratorDefinition] ...
+
+DROP SHARDING KEY GENERATOR keyGeneratorName [, keyGeneratorName] ...
+
shardingTableRuleDefinition:
shardingAutoTableRule | shardingTableRule
@@ -73,9 +79,6 @@ keyGenerateConstruction
shardingStrategy:
TYPE=strategyType, shardingColumn, shardingAlgorithm
-
-shardingColumn:
- SHARDING_COLUMN=columnName
shardingAlgorithm:
existingAlgorithm | autoCreativeAlgorithm
@@ -96,7 +99,10 @@ algorithmProperties:
algorithmProperty [, algorithmProperty] ...
algorithmProperty:
- key=value
+ key=value
+
+keyGeneratorDefinition:
+ keyGeneratorName (algorithmDefinition)
```
- `RESOURCES` 需使用 RDL 管理的数据源资源
- `shardingAlgorithmType` 指定自动分片算法类型,请参考 [自动分片算法](/cn/user-manual/shardingsphere-jdbc/builtin-algorithm/sharding/)
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.en.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.en.md
index 736e059..e7b6e5d 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.en.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.en.md
@@ -20,12 +20,18 @@ ALTER DEFAULT SHARDING shardingScope STRATEGY (shardingStrategy)
DROP DEFAULT SHARDING shardingScope STRATEGY;
-CREATE SHARDING ALGORITHM shardingAlgorithmDefinition [, shardingAlgorithmDefinition] ...
+CREATE SHARDING ALGORITHM shardingAlgorithmDefinition [, shardingAlgorithmDefinition] ...
-ALTER SHARDING ALGORITHM shardingAlgorithmDefinition [, shardingAlgorithmDefinition] ...
+ALTER SHARDING ALGORITHM shardingAlgorithmDefinition [, shardingAlgorithmDefinition] ...
DROP SHARDING ALGORITHM algorithmName [, algorithmName] ...
+CREATE SHARDING KEY GENERATOR keyGeneratorDefinition [, keyGeneratorDefinition] ...
+
+ALTER SHARDING KEY GENERATOR keyGeneratorDefinition [, keyGeneratorDefinition] ...
+
+DROP SHARDING KEY GENERATOR keyGeneratorName [, keyGeneratorName] ...
+
shardingTableRuleDefinition:
shardingAutoTableRule | shardingTableRule
@@ -73,9 +79,6 @@ keyGenerateConstruction
shardingStrategy:
TYPE=strategyType, shardingColumn, shardingAlgorithm
-
-shardingColumn:
- SHARDING_COLUMN=columnName
shardingAlgorithm:
existingAlgorithm | autoCreativeAlgorithm
@@ -96,7 +99,10 @@ algorithmProperties:
algorithmProperty [, algorithmProperty] ...
algorithmProperty:
- key=value
+ key=value
+
+keyGeneratorDefinition:
+ keyGeneratorName (algorithmDefinition)
```
- `RESOURCES` needs to use data source resources managed by RDL
- `shardingAlgorithmType` specifies the type of automatic sharding algorithm, please refer to [Auto Sharding Algorithm](/en/user-manual/shardingsphere-jdbc/builtin-algorithm/sharding/)
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.cn.md
index 0d91f1e..9e5a61b 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.cn.md
@@ -12,6 +12,8 @@ SHOW SHARDING TABLE tableRule | RULES [FROM schemaName]
SHOW SHARDING ALGORITHMS [FROM schemaName]
+SHOW SHARDING KEY GENERATORS [FROM schemaName]
+
SHOW DEFAULT SHARDING STRATEGY
SHOW SHARDING TABLE NODES;
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.en.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.en.md
index b025b4e..5c3a941 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.en.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.en.md
@@ -12,6 +12,8 @@ SHOW SHARDING TABLE tableRule | RULES [FROM schemaName]
SHOW SHARDING ALGORITHMS [FROM schemaName]
+SHOW SHARDING KEY GENERATORS [FROM schemaName]
+
SHOW DEFAULT SHARDING STRATEGY
SHOW SHARDING TABLE NODES;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RDLStatement.g4 b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RDLStatement.g4
index c0b12ee..9959791 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RDLStatement.g4
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RDLStatement.g4
@@ -48,7 +48,7 @@ dropDefaultShardingStrategy
;
createShardingKeyGenerator
- : CREATE SHARDING KEY GENERATOR keyGeneratorDefination (COMMA keyGeneratorDefination)*
+ : CREATE SHARDING KEY GENERATOR keyGeneratorDefinition (COMMA keyGeneratorDefinition)*
;
alterShardingTableRule
@@ -68,7 +68,7 @@ alterShardingAlgorithm
;
alterShardingKeyGenerator
- : ALTER SHARDING KEY GENERATOR keyGeneratorDefination (COMMA keyGeneratorDefination)*
+ : ALTER SHARDING KEY GENERATOR keyGeneratorDefinition (COMMA keyGeneratorDefinition)*
;
dropShardingTableRule
@@ -103,7 +103,7 @@ shardingTableRule
: tableName LP dataNodes (COMMA databaseStrategy)? (COMMA tableStrategy)? (COMMA keyGenerateDeclaration)? RP
;
-keyGeneratorDefination
+keyGeneratorDefinition
: keyGeneratorName LP algorithmDefinition RP
;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java
index 938b86d..66e13d5 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java
@@ -47,7 +47,7 @@ import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatement
import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.DropShardingTableRuleContext;
import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.KeyGenerateDefinitionContext;
import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.KeyGenerateStrategyContext;
-import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.KeyGeneratorDefinationContext;
+import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.KeyGeneratorDefinitionContext;
import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.ResourcesContext;
import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.SchemaNameContext;
import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.SetShardingHintDatabaseValueContext;
@@ -418,15 +418,15 @@ public final class ShardingDistSQLStatementVisitor extends ShardingDistSQLStatem
@Override
public ASTNode visitCreateShardingKeyGenerator(final CreateShardingKeyGeneratorContext ctx) {
- return new CreateShardingKeyGeneratorStatement(ctx.keyGeneratorDefination().stream().map(this::buildShardingKeyGeneratorSegment).collect(Collectors.toCollection(LinkedList::new)));
+ return new CreateShardingKeyGeneratorStatement(ctx.keyGeneratorDefinition().stream().map(this::buildShardingKeyGeneratorSegment).collect(Collectors.toCollection(LinkedList::new)));
}
@Override
public ASTNode visitAlterShardingKeyGenerator(final AlterShardingKeyGeneratorContext ctx) {
- return new AlterShardingKeyGeneratorStatement(ctx.keyGeneratorDefination().stream().map(this::buildShardingKeyGeneratorSegment).collect(Collectors.toCollection(LinkedList::new)));
+ return new AlterShardingKeyGeneratorStatement(ctx.keyGeneratorDefinition().stream().map(this::buildShardingKeyGeneratorSegment).collect(Collectors.toCollection(LinkedList::new)));
}
- private ShardingKeyGeneratorSegment buildShardingKeyGeneratorSegment(final KeyGeneratorDefinationContext ctx) {
+ private ShardingKeyGeneratorSegment buildShardingKeyGeneratorSegment(final KeyGeneratorDefinitionContext ctx) {
return new ShardingKeyGeneratorSegment(getIdentifierValue(ctx.keyGeneratorName()), (AlgorithmSegment) visitAlgorithmDefinition(ctx.algorithmDefinition()));
}