This is an automated email from the ASF dual-hosted git repository.
wuweijie 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 1cd5f54 Rename functionDefinition to algorithmDefinition (#10825)
1cd5f54 is described below
commit 1cd5f54acdc67a771be57d10f0ecea4fb12e2018
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Jun 16 00:14:57 2021 +0800
Rename functionDefinition to algorithmDefinition (#10825)
* Rename AlgorithmSegment
* Rename functionDefinition for db-discovery
* Use rule name with drop db-discovery rule
* Use resource name with drop db-discovery rule
* Rename functionDefinition for encrypt
* Rename functionDefinition for readwrite splitting
* Rename functionDefinition for sharding
---
...{FunctionSegment.java => AlgorithmSegment.java} | 8 +--
.../antlr4/imports/db-discovery/RDLStatement.g4 | 42 ++++++++-------
.../DatabaseDiscoveryRuleSQLStatementVisitor.java | 62 +++++++++-------------
.../converter/EncryptRuleStatementConverter.java | 4 +-
.../EncryptRuleStatementConverterTest.java | 4 +-
.../main/antlr4/imports/encrypt/RDLStatement.g4 | 54 +++++++++----------
.../main/antlr4/imports/encrypt/RQLStatement.g4 | 4 +-
.../core/EncryptRuleSQLStatementVisitor.java | 52 +++++++++---------
.../statement/segment/EncryptColumnSegment.java | 4 +-
.../core/EncryptRuleStatementParserEngineTest.java | 12 ++---
.../imports/readwrite-splitting/RDLStatement.g4 | 24 ++++-----
.../ReadwriteSplittingRuleSQLStatementVisitor.java | 49 +++++++++--------
.../converter/ShardingRuleStatementConverter.java | 16 +++---
.../ShardingRuleStatementConverterTest.java | 4 +-
.../main/antlr4/imports/sharding/RDLStatement.g4 | 18 +++----
.../core/ShardingRuleSQLStatementVisitor.java | 33 ++++++------
.../parser/statement/segment/TableRuleSegment.java | 6 +--
.../ShardingRuleStatementParserEngineTest.java | 16 +++---
.../rdl/impl/AlterEncryptRuleBackendHandler.java | 2 +-
.../impl/AlterShardingTableRuleBackendHandler.java | 4 +-
.../rdl/impl/CreateEncryptRuleBackendHandler.java | 2 +-
.../CreateShardingTableRuleBackendHandler.java | 4 +-
.../impl/AlterEncryptRuleBackendHandlerTest.java | 4 +-
.../AlterShardingTableRuleBackendHandlerTest.java | 6 +--
.../impl/CreateEncryptRuleBackendHandlerTest.java | 4 +-
.../CreateShardingTableRuleBackendHandlerTest.java | 6 +--
26 files changed, 216 insertions(+), 228 deletions(-)
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/FunctionSegment.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/AlgorithmSegment.java
similarity index 86%
rename from
shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/FunctionSegment.java
rename to
shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/AlgorithmSegment.java
index 958ba48..83642d1 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/FunctionSegment.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/AlgorithmSegment.java
@@ -24,13 +24,13 @@ import
org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
import java.util.Properties;
/**
- * Function segment.
+ * Algorithm segment.
*/
@RequiredArgsConstructor
@Getter
-public final class FunctionSegment implements ASTNode {
+public final class AlgorithmSegment implements ASTNode {
- private final String algorithmName;
+ private final String name;
- private final Properties algorithmProps;
+ private final Properties props;
}
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/src/main/antlr4/imports/db-discovery/RDLStatement.g4
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/src/main/antlr4/imports/db-discovery/RDLStatement.g4
index 93139ee..1266c37 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/src/main/antlr4/imports/db-discovery/RDLStatement.g4
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/src/main/antlr4/imports/db-discovery/RDLStatement.g4
@@ -19,42 +19,46 @@ grammar RDLStatement;
import Keyword, Literals, Symbol;
-resources
- : RESOURCES LP IDENTIFIER (COMMA IDENTIFIER)* RP
+createDatabaseDiscoveryRule
+ : CREATE DB_DISCOVERY RULE databaseDiscoveryRuleDefinition (COMMA
databaseDiscoveryRuleDefinition)*
;
-ruleName
- : IDENTIFIER
+alterDatabaseDiscoveryRule
+ : ALTER DB_DISCOVERY RULE databaseDiscoveryRuleDefinition (COMMA
databaseDiscoveryRuleDefinition)*
;
-functionDefinition
- : TYPE LP NAME EQ functionName (COMMA PROPERTIES LP algorithmProperties?
RP)? RP
+dropDatabaseDiscoveryRule
+ : DROP DB_DISCOVERY RULE ruleName (COMMA ruleName)*
;
-functionName
+databaseDiscoveryRuleDefinition
+ : ruleName LP resources COMMA algorithmDefinition RP
+ ;
+
+ruleName
: IDENTIFIER
;
-algorithmProperties
- : algorithmProperty (COMMA algorithmProperty)*
+resources
+ : RESOURCES LP resourceName (COMMA resourceName)* RP
;
-algorithmProperty
- : key=(IDENTIFIER | STRING) EQ value=(NUMBER | INT | STRING)
+resourceName
+ : IDENTIFIER
;
-createDatabaseDiscoveryRule
- : CREATE DB_DISCOVERY RULE databaseDiscoveryRuleDefinition (COMMA
databaseDiscoveryRuleDefinition)*
+algorithmDefinition
+ : TYPE LP NAME EQ algorithmName (COMMA PROPERTIES LP algorithmProperties?
RP)? RP
;
-databaseDiscoveryRuleDefinition
- : ruleName LP resources COMMA functionDefinition RP
+algorithmName
+ : IDENTIFIER
;
-alterDatabaseDiscoveryRule
- : ALTER DB_DISCOVERY RULE databaseDiscoveryRuleDefinition (COMMA
databaseDiscoveryRuleDefinition)*
+algorithmProperties
+ : algorithmProperty (COMMA algorithmProperty)*
;
-dropDatabaseDiscoveryRule
- : DROP DB_DISCOVERY RULE IDENTIFIER (COMMA IDENTIFIER)*
+algorithmProperty
+ : key=(IDENTIFIER | STRING) EQ value=(NUMBER | INT | STRING)
;
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/parser/core/DatabaseDiscoveryRuleSQLStatementVisitor.java
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/parser/core/DatabaseDiscoveryRuleSQLStatementVisitor.java
index cc89f83..1c2ec1a 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/parser/core/DatabaseDiscoveryRuleSQLStatementVisitor.java
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/parser/core/DatabaseDiscoveryRuleSQLStatementVisitor.java
@@ -17,29 +17,28 @@
package org.apache.shardingsphere.dbdiscovery.distsql.parser.core;
-import org.antlr.v4.runtime.tree.TerminalNode;
+import
org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.AlterDatabaseDiscoveryRuleStatement;
+import
org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.CreateDatabaseDiscoveryRuleStatement;
+import
org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.DropDatabaseDiscoveryRuleStatement;
+import
org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.ShowDatabaseDiscoveryRulesStatement;
+import
org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.segment.DatabaseDiscoveryRuleSegment;
import
org.apache.shardingsphere.distsql.parser.autogen.DatabaseDiscoveryRuleStatementBaseVisitor;
+import
org.apache.shardingsphere.distsql.parser.autogen.DatabaseDiscoveryRuleStatementParser.AlgorithmDefinitionContext;
import
org.apache.shardingsphere.distsql.parser.autogen.DatabaseDiscoveryRuleStatementParser.AlgorithmPropertiesContext;
import
org.apache.shardingsphere.distsql.parser.autogen.DatabaseDiscoveryRuleStatementParser.AlgorithmPropertyContext;
import
org.apache.shardingsphere.distsql.parser.autogen.DatabaseDiscoveryRuleStatementParser.AlterDatabaseDiscoveryRuleContext;
import
org.apache.shardingsphere.distsql.parser.autogen.DatabaseDiscoveryRuleStatementParser.CreateDatabaseDiscoveryRuleContext;
import
org.apache.shardingsphere.distsql.parser.autogen.DatabaseDiscoveryRuleStatementParser.DatabaseDiscoveryRuleDefinitionContext;
import
org.apache.shardingsphere.distsql.parser.autogen.DatabaseDiscoveryRuleStatementParser.DropDatabaseDiscoveryRuleContext;
-import
org.apache.shardingsphere.distsql.parser.autogen.DatabaseDiscoveryRuleStatementParser.FunctionDefinitionContext;
+import
org.apache.shardingsphere.distsql.parser.autogen.DatabaseDiscoveryRuleStatementParser.RuleNameContext;
import
org.apache.shardingsphere.distsql.parser.autogen.DatabaseDiscoveryRuleStatementParser.SchemaNameContext;
import
org.apache.shardingsphere.distsql.parser.autogen.DatabaseDiscoveryRuleStatementParser.ShowDatabaseDiscoveryRulesContext;
-import org.apache.shardingsphere.distsql.parser.segment.FunctionSegment;
-import
org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.segment.DatabaseDiscoveryRuleSegment;
-import
org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.AlterDatabaseDiscoveryRuleStatement;
-import
org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.CreateDatabaseDiscoveryRuleStatement;
-import
org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.DropDatabaseDiscoveryRuleStatement;
-import
org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.ShowDatabaseDiscoveryRulesStatement;
+import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.SchemaSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
-import java.util.Objects;
import java.util.Properties;
import java.util.stream.Collectors;
@@ -54,54 +53,43 @@ public final class DatabaseDiscoveryRuleSQLStatementVisitor
extends DatabaseDisc
}
@Override
- public ASTNode visitDatabaseDiscoveryRuleDefinition(final
DatabaseDiscoveryRuleDefinitionContext ctx) {
- DatabaseDiscoveryRuleSegment result = new
DatabaseDiscoveryRuleSegment();
- result.setName(ctx.ruleName().getText());
- result.setDataSources(ctx.resources().IDENTIFIER().stream().map(each
-> new
IdentifierValue(each.getText()).getValue()).collect(Collectors.toList()));
-
result.setDiscoveryTypeName(ctx.functionDefinition().functionName().getText());
-
result.setProps(buildAlgorithmProperties(ctx.functionDefinition().algorithmProperties()));
- return result;
- }
-
- @Override
public ASTNode visitAlterDatabaseDiscoveryRule(final
AlterDatabaseDiscoveryRuleContext ctx) {
return new
AlterDatabaseDiscoveryRuleStatement(ctx.databaseDiscoveryRuleDefinition().stream().map(each
-> (DatabaseDiscoveryRuleSegment) visit(each)).collect(Collectors.toList()));
}
@Override
public ASTNode visitDropDatabaseDiscoveryRule(final
DropDatabaseDiscoveryRuleContext ctx) {
- return new
DropDatabaseDiscoveryRuleStatement(ctx.IDENTIFIER().stream().map(TerminalNode::getText).collect(Collectors.toList()));
+ return new
DropDatabaseDiscoveryRuleStatement(ctx.ruleName().stream().map(RuleNameContext::getText).collect(Collectors.toList()));
}
@Override
- public ASTNode visitSchemaName(final SchemaNameContext ctx) {
- return new SchemaSegment(ctx.getStart().getStartIndex(),
ctx.getStop().getStopIndex(), new IdentifierValue(ctx.getText()));
+ public ASTNode visitShowDatabaseDiscoveryRules(final
ShowDatabaseDiscoveryRulesContext ctx) {
+ return new ShowDatabaseDiscoveryRulesStatement(null ==
ctx.schemaName() ? null : (SchemaSegment) visit(ctx.schemaName()));
}
@Override
- public ASTNode visitShowDatabaseDiscoveryRules(final
ShowDatabaseDiscoveryRulesContext ctx) {
- return new
ShowDatabaseDiscoveryRulesStatement(Objects.nonNull(ctx.schemaName()) ?
(SchemaSegment) visit(ctx.schemaName()) : null);
+ public ASTNode visitDatabaseDiscoveryRuleDefinition(final
DatabaseDiscoveryRuleDefinitionContext ctx) {
+ DatabaseDiscoveryRuleSegment result = new
DatabaseDiscoveryRuleSegment();
+ result.setName(ctx.ruleName().getText());
+ result.setDataSources(ctx.resources().resourceName().stream().map(each
-> new
IdentifierValue(each.getText()).getValue()).collect(Collectors.toList()));
+
result.setDiscoveryTypeName(ctx.algorithmDefinition().algorithmName().getText());
+
result.setProps(getAlgorithmProperties(ctx.algorithmDefinition().algorithmProperties()));
+ return result;
}
- private Properties buildAlgorithmProperties(final
AlgorithmPropertiesContext ctx) {
- Properties result = new Properties();
- for (AlgorithmPropertyContext each : ctx.algorithmProperty()) {
- result.setProperty(new
IdentifierValue(each.key.getText()).getValue(), new
IdentifierValue(each.value.getText()).getValue());
- }
- return result;
+ @Override
+ public ASTNode visitSchemaName(final SchemaNameContext ctx) {
+ return new SchemaSegment(ctx.getStart().getStartIndex(),
ctx.getStop().getStopIndex(), new IdentifierValue(ctx.getText()));
}
@Override
- public ASTNode visitFunctionDefinition(final FunctionDefinitionContext
ctx) {
- return new FunctionSegment(ctx.functionName().getText(),
getAlgorithmProperties(ctx));
+ public ASTNode visitAlgorithmDefinition(final AlgorithmDefinitionContext
ctx) {
+ return new AlgorithmSegment(ctx.algorithmName().getText(), null ==
ctx.algorithmProperties() ? new Properties() :
getAlgorithmProperties(ctx.algorithmProperties()));
}
- private Properties getAlgorithmProperties(final FunctionDefinitionContext
ctx) {
+ private Properties getAlgorithmProperties(final AlgorithmPropertiesContext
ctx) {
Properties result = new Properties();
- if (null == ctx.algorithmProperties()) {
- return result;
- }
- for (AlgorithmPropertyContext each :
ctx.algorithmProperties().algorithmProperty()) {
+ for (AlgorithmPropertyContext each : ctx.algorithmProperty()) {
result.setProperty(new
IdentifierValue(each.key.getText()).getValue(), new
IdentifierValue(each.value.getText()).getValue());
}
return result;
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/yaml/converter/EncryptRuleStatementConverter.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/yaml/converter/EncryptRuleStatementConverter.java
index cb0b54c..c07e3ab 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/yaml/converter/EncryptRuleStatementConverter.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/yaml/converter/EncryptRuleStatementConverter.java
@@ -72,8 +72,8 @@ public final class EncryptRuleStatementConverter {
private static YamlShardingSphereAlgorithmConfiguration
buildYamlShardingSphereAlgorithmConfiguration(final EncryptColumnSegment
encryptColumnSegment) {
YamlShardingSphereAlgorithmConfiguration result = new
YamlShardingSphereAlgorithmConfiguration();
- result.setType(encryptColumnSegment.getEncryptor().getAlgorithmName());
-
result.setProps(encryptColumnSegment.getEncryptor().getAlgorithmProps());
+ result.setType(encryptColumnSegment.getEncryptor().getName());
+ result.setProps(encryptColumnSegment.getEncryptor().getProps());
return result;
}
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/converter/EncryptRuleStatementConverterTest.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/converter/EncryptRuleStatementConverterTest.java
index d27db9a..760befb 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/converter/EncryptRuleStatementConverterTest.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/converter/EncryptRuleStatementConverterTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.encrypt.yaml.converter;
-import org.apache.shardingsphere.distsql.parser.segment.FunctionSegment;
+import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import
org.apache.shardingsphere.encrypt.distsql.parser.statement.segment.EncryptColumnSegment;
import
org.apache.shardingsphere.encrypt.distsql.parser.statement.segment.EncryptRuleSegment;
import
org.apache.shardingsphere.encrypt.yaml.config.YamlEncryptRuleConfiguration;
@@ -54,7 +54,7 @@ public final class EncryptRuleStatementConverterTest {
encryptColumnSegment.setCipherColumn("user_cipher");
Properties properties = new Properties();
properties.setProperty("MD5-key", "MD5-value");
- encryptColumnSegment.setEncryptor(new FunctionSegment("MD5",
properties));
+ encryptColumnSegment.setEncryptor(new AlgorithmSegment("MD5",
properties));
return Collections.singleton(encryptColumnSegment);
}
}
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/main/antlr4/imports/encrypt/RDLStatement.g4
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/main/antlr4/imports/encrypt/RDLStatement.g4
index a764b0e..c33d12f 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/main/antlr4/imports/encrypt/RDLStatement.g4
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/main/antlr4/imports/encrypt/RDLStatement.g4
@@ -19,58 +19,58 @@ grammar RDLStatement;
import Keyword, Literals, Symbol;
-resourceName
- : IDENTIFIER
+createEncryptRule
+ : CREATE ENCRYPT RULE encryptRuleDefinition (COMMA encryptRuleDefinition)*
;
-tableName
- : IDENTIFIER
+alterEncryptRule
+ : ALTER ENCRYPT RULE encryptRuleDefinition (COMMA encryptRuleDefinition)*
;
-columnName
- : IDENTIFIER
+dropEncryptRule
+ : DROP ENCRYPT RULE tableName (COMMA tableName)*
;
-functionDefinition
- : TYPE LP NAME EQ functionName (COMMA PROPERTIES LP algorithmProperties?
RP)? RP
+encryptRuleDefinition
+ : tableName LP (RESOURCE EQ resourceName COMMA)? COLUMNS LP
columnDefinition (COMMA columnDefinition)* RP RP
;
-functionName
+tableName
: IDENTIFIER
;
-algorithmProperties
- : algorithmProperty (COMMA algorithmProperty)*
+resourceName
+ : IDENTIFIER
;
-algorithmProperty
- : key=(IDENTIFIER | STRING) EQ value=(NUMBER | INT | STRING)
+columnDefinition
+ : LP NAME EQ columnName (COMMA PLAIN EQ plainColumnName)? COMMA CIPHER EQ
cipherColumnName COMMA algorithmDefinition RP
;
-createEncryptRule
- : CREATE ENCRYPT RULE encryptRuleDefinition (COMMA encryptRuleDefinition)*
+columnName
+ : IDENTIFIER
;
-encryptRuleDefinition
- : tableName LP (RESOURCE EQ resourceName COMMA)? COLUMNS LP
columnDefinition (COMMA columnDefinition)* RP RP
+plainColumnName
+ : IDENTIFIER
;
-columnDefinition
- : LP NAME EQ columnName (COMMA PLAIN EQ plainColumnName)? COMMA CIPHER EQ
cipherColumnName COMMA functionDefinition RP
+cipherColumnName
+ : IDENTIFIER
;
-alterEncryptRule
- : ALTER ENCRYPT RULE encryptRuleDefinition (COMMA encryptRuleDefinition)*
+algorithmDefinition
+ : TYPE LP NAME EQ algorithmName (COMMA PROPERTIES LP algorithmProperties?
RP)? RP
;
-dropEncryptRule
- : DROP ENCRYPT RULE IDENTIFIER (COMMA IDENTIFIER)*
+algorithmName
+ : IDENTIFIER
;
-plainColumnName
- : IDENTIFIER
+algorithmProperties
+ : algorithmProperty (COMMA algorithmProperty)*
;
-cipherColumnName
- : IDENTIFIER
+algorithmProperty
+ : key=(IDENTIFIER | STRING) EQ value=(NUMBER | INT | STRING)
;
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/main/antlr4/imports/encrypt/RQLStatement.g4
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/main/antlr4/imports/encrypt/RQLStatement.g4
index c393c22..4a75e26 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/main/antlr4/imports/encrypt/RQLStatement.g4
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/main/antlr4/imports/encrypt/RQLStatement.g4
@@ -27,10 +27,10 @@ tableRule
: RULE tableName
;
-schemaName
+tableName
: IDENTIFIER
;
-tableName
+schemaName
: IDENTIFIER
;
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptRuleSQLStatementVisitor.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptRuleSQLStatementVisitor.java
index 084694c..f7ea17f 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptRuleSQLStatementVisitor.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptRuleSQLStatementVisitor.java
@@ -17,32 +17,30 @@
package org.apache.shardingsphere.encrypt.distsql.parser.core;
-import org.antlr.v4.runtime.tree.TerminalNode;
import
org.apache.shardingsphere.distsql.parser.autogen.EncryptRuleStatementBaseVisitor;
+import
org.apache.shardingsphere.distsql.parser.autogen.EncryptRuleStatementParser.AlgorithmDefinitionContext;
import
org.apache.shardingsphere.distsql.parser.autogen.EncryptRuleStatementParser.AlgorithmPropertyContext;
import
org.apache.shardingsphere.distsql.parser.autogen.EncryptRuleStatementParser.AlterEncryptRuleContext;
import
org.apache.shardingsphere.distsql.parser.autogen.EncryptRuleStatementParser.ColumnDefinitionContext;
import
org.apache.shardingsphere.distsql.parser.autogen.EncryptRuleStatementParser.CreateEncryptRuleContext;
import
org.apache.shardingsphere.distsql.parser.autogen.EncryptRuleStatementParser.DropEncryptRuleContext;
import
org.apache.shardingsphere.distsql.parser.autogen.EncryptRuleStatementParser.EncryptRuleDefinitionContext;
-import
org.apache.shardingsphere.distsql.parser.autogen.EncryptRuleStatementParser.FunctionDefinitionContext;
import
org.apache.shardingsphere.distsql.parser.autogen.EncryptRuleStatementParser.SchemaNameContext;
import
org.apache.shardingsphere.distsql.parser.autogen.EncryptRuleStatementParser.ShowEncryptRulesContext;
import
org.apache.shardingsphere.distsql.parser.autogen.EncryptRuleStatementParser.TableNameContext;
-import org.apache.shardingsphere.distsql.parser.segment.FunctionSegment;
-import
org.apache.shardingsphere.encrypt.distsql.parser.statement.segment.EncryptColumnSegment;
-import
org.apache.shardingsphere.encrypt.distsql.parser.statement.segment.EncryptRuleSegment;
+import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import
org.apache.shardingsphere.encrypt.distsql.parser.statement.AlterEncryptRuleStatement;
import
org.apache.shardingsphere.encrypt.distsql.parser.statement.CreateEncryptRuleStatement;
import
org.apache.shardingsphere.encrypt.distsql.parser.statement.DropEncryptRuleStatement;
import
org.apache.shardingsphere.encrypt.distsql.parser.statement.ShowEncryptRulesStatement;
+import
org.apache.shardingsphere.encrypt.distsql.parser.statement.segment.EncryptColumnSegment;
+import
org.apache.shardingsphere.encrypt.distsql.parser.statement.segment.EncryptRuleSegment;
import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.SchemaSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.TableNameSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
-import java.util.Objects;
import java.util.Properties;
import java.util.stream.Collectors;
@@ -57,44 +55,44 @@ public final class EncryptRuleSQLStatementVisitor extends
EncryptRuleStatementBa
}
@Override
- public ASTNode visitEncryptRuleDefinition(final
EncryptRuleDefinitionContext ctx) {
- return new EncryptRuleSegment(ctx.tableName().getText(),
ctx.columnDefinition().stream().map(each -> (EncryptColumnSegment)
visit(each)).collect(Collectors.toList()));
+ public ASTNode visitAlterEncryptRule(final AlterEncryptRuleContext ctx) {
+ return new
AlterEncryptRuleStatement(ctx.encryptRuleDefinition().stream().map(each ->
(EncryptRuleSegment) visit(each)).collect(Collectors.toList()));
}
@Override
- public ASTNode visitColumnDefinition(final ColumnDefinitionContext ctx) {
- EncryptColumnSegment result = new EncryptColumnSegment();
- result.setName(ctx.columnName().getText());
- result.setCipherColumn(ctx.cipherColumnName().getText());
- if (Objects.nonNull(ctx.plainColumnName())) {
- result.setPlainColumn(ctx.plainColumnName().getText());
- }
- result.setEncryptor((FunctionSegment) visit(ctx.functionDefinition()));
- return result;
+ public ASTNode visitDropEncryptRule(final DropEncryptRuleContext ctx) {
+ return new
DropEncryptRuleStatement(ctx.tableName().stream().map(TableNameContext::getText).collect(Collectors.toList()));
}
@Override
- public ASTNode visitAlterEncryptRule(final AlterEncryptRuleContext ctx) {
- return new
AlterEncryptRuleStatement(ctx.encryptRuleDefinition().stream().map(each ->
(EncryptRuleSegment) visit(each)).collect(Collectors.toList()));
+ public ASTNode visitShowEncryptRules(final ShowEncryptRulesContext ctx) {
+ return new ShowEncryptRulesStatement(null == ctx.tableRule() ? null :
ctx.tableRule().tableName().getText(),
+ null == ctx.schemaName() ? null : (SchemaSegment)
visit(ctx.schemaName()));
}
@Override
- public ASTNode visitDropEncryptRule(final DropEncryptRuleContext ctx) {
- return new
DropEncryptRuleStatement(ctx.IDENTIFIER().stream().map(TerminalNode::getText).collect(Collectors.toList()));
+ public ASTNode visitEncryptRuleDefinition(final
EncryptRuleDefinitionContext ctx) {
+ return new EncryptRuleSegment(ctx.tableName().getText(),
ctx.columnDefinition().stream().map(each -> (EncryptColumnSegment)
visit(each)).collect(Collectors.toList()));
}
@Override
- public ASTNode visitShowEncryptRules(final ShowEncryptRulesContext ctx) {
- return new ShowEncryptRulesStatement(Objects.nonNull(ctx.tableRule())
? ctx.tableRule().tableName().getText() : null,
- Objects.nonNull(ctx.schemaName()) ? (SchemaSegment)
visit(ctx.schemaName()) : null);
+ public ASTNode visitColumnDefinition(final ColumnDefinitionContext ctx) {
+ EncryptColumnSegment result = new EncryptColumnSegment();
+ result.setName(ctx.columnName().getText());
+ result.setCipherColumn(ctx.cipherColumnName().getText());
+ if (null != ctx.plainColumnName()) {
+ result.setPlainColumn(ctx.plainColumnName().getText());
+ }
+ result.setEncryptor((AlgorithmSegment)
visit(ctx.algorithmDefinition()));
+ return result;
}
@Override
- public ASTNode visitFunctionDefinition(final FunctionDefinitionContext
ctx) {
- return new FunctionSegment(ctx.functionName().getText(),
getAlgorithmProperties(ctx));
+ public ASTNode visitAlgorithmDefinition(final AlgorithmDefinitionContext
ctx) {
+ return new AlgorithmSegment(ctx.algorithmName().getText(),
getAlgorithmProperties(ctx));
}
- private Properties getAlgorithmProperties(final FunctionDefinitionContext
ctx) {
+ private Properties getAlgorithmProperties(final AlgorithmDefinitionContext
ctx) {
Properties result = new Properties();
if (null == ctx.algorithmProperties()) {
return result;
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/statement/segment/EncryptColumnSegment.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/statement/segment/EncryptColumnSegment.java
index aece6a8..f97e542 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/statement/segment/EncryptColumnSegment.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/statement/segment/EncryptColumnSegment.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.encrypt.distsql.parser.statement.segment;
import lombok.Getter;
import lombok.Setter;
-import org.apache.shardingsphere.distsql.parser.segment.FunctionSegment;
+import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
/**
@@ -35,5 +35,5 @@ public final class EncryptColumnSegment implements ASTNode {
private String cipherColumn;
- private FunctionSegment encryptor;
+ private AlgorithmSegment encryptor;
}
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/test/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptRuleStatementParserEngineTest.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/test/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptRuleStatementParserEngineTest.java
index bde405b..e9ca297 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/test/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptRuleStatementParserEngineTest.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/src/test/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptRuleStatementParserEngineTest.java
@@ -72,11 +72,11 @@ public final class EncryptRuleStatementParserEngineTest {
assertThat(encryptColumnSegments.get(0).getName(), is("user_id"));
assertThat(encryptColumnSegments.get(0).getCipherColumn(),
is("user_cipher"));
assertThat(encryptColumnSegments.get(0).getPlainColumn(),
is("user_plain"));
-
assertThat(encryptColumnSegments.get(0).getEncryptor().getAlgorithmName(),
is("AES"));
-
assertThat(encryptColumnSegments.get(0).getEncryptor().getAlgorithmProps().get("aes-key-value"),
is("123456abc"));
+ assertThat(encryptColumnSegments.get(0).getEncryptor().getName(),
is("AES"));
+
assertThat(encryptColumnSegments.get(0).getEncryptor().getProps().get("aes-key-value"),
is("123456abc"));
assertThat(encryptColumnSegments.get(1).getName(), is("order_id"));
assertThat(encryptColumnSegments.get(1).getCipherColumn(),
is("order_cipher"));
-
assertThat(encryptColumnSegments.get(1).getEncryptor().getAlgorithmName(),
is("MD5"));
+ assertThat(encryptColumnSegments.get(1).getEncryptor().getName(),
is("MD5"));
}
@Test
@@ -92,11 +92,11 @@ public final class EncryptRuleStatementParserEngineTest {
assertThat(encryptColumnSegments.get(0).getName(), is("user_id"));
assertThat(encryptColumnSegments.get(0).getCipherColumn(),
is("user_cipher"));
assertThat(encryptColumnSegments.get(0).getPlainColumn(),
is("user_plain"));
-
assertThat(encryptColumnSegments.get(0).getEncryptor().getAlgorithmName(),
is("AES"));
-
assertThat(encryptColumnSegments.get(0).getEncryptor().getAlgorithmProps().get("aes-key-value"),
is("123456abc"));
+ assertThat(encryptColumnSegments.get(0).getEncryptor().getName(),
is("AES"));
+
assertThat(encryptColumnSegments.get(0).getEncryptor().getProps().get("aes-key-value"),
is("123456abc"));
assertThat(encryptColumnSegments.get(1).getName(), is("order_id"));
assertThat(encryptColumnSegments.get(1).getCipherColumn(),
is("order_cipher"));
-
assertThat(encryptColumnSegments.get(1).getEncryptor().getAlgorithmName(),
is("MD5"));
+ assertThat(encryptColumnSegments.get(1).getEncryptor().getName(),
is("MD5"));
}
@Test
diff --git
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/src/main/antlr4/imports/readwrite-splitting/RDLStatement.g4
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/src/main/antlr4/imports/readwrite-splitting/RDLStatement.g4
index 6f4c8a6..d1714df 100644
---
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/src/main/antlr4/imports/readwrite-splitting/RDLStatement.g4
+++
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/src/main/antlr4/imports/readwrite-splitting/RDLStatement.g4
@@ -23,8 +23,16 @@ createReadwriteSplittingRule
: CREATE READWRITE_SPLITTING RULE readwriteSplittingRuleDefinition (COMMA
readwriteSplittingRuleDefinition)*
;
+alterReadwriteSplittingRule
+ : ALTER READWRITE_SPLITTING RULE readwriteSplittingRuleDefinition (COMMA
readwriteSplittingRuleDefinition)*
+ ;
+
+dropReadwriteSplittingRule
+ : DROP READWRITE_SPLITTING RULE IDENTIFIER (COMMA IDENTIFIER)*
+ ;
+
readwriteSplittingRuleDefinition
- : ruleName LP (staticReadwriteSplittingRuleDefinition |
dynamicReadwriteSplittingRuleDefinition) (COMMA functionDefinition)? RP
+ : ruleName LP (staticReadwriteSplittingRuleDefinition |
dynamicReadwriteSplittingRuleDefinition) (COMMA algorithmDefinition)? RP
;
staticReadwriteSplittingRuleDefinition
@@ -35,10 +43,6 @@ dynamicReadwriteSplittingRuleDefinition
: AUTO_AWARE_RESOURCE EQ IDENTIFIER
;
-alterReadwriteSplittingRule
- : ALTER READWRITE_SPLITTING RULE readwriteSplittingRuleDefinition (COMMA
readwriteSplittingRuleDefinition)*
- ;
-
writeResourceName
: resourceName
;
@@ -51,15 +55,11 @@ ruleName
: IDENTIFIER
;
-dropReadwriteSplittingRule
- : DROP READWRITE_SPLITTING RULE IDENTIFIER (COMMA IDENTIFIER)*
- ;
-
-functionDefinition
- : TYPE LP NAME EQ functionName (COMMA PROPERTIES LP algorithmProperties?
RP)? RP
+algorithmDefinition
+ : TYPE LP NAME EQ algorithmName (COMMA PROPERTIES LP algorithmProperties?
RP)? RP
;
-functionName
+algorithmName
: IDENTIFIER
;
diff --git
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingRuleSQLStatementVisitor.java
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingRuleSQLStatementVisitor.java
index 94fffd0..72b78e8 100644
---
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingRuleSQLStatementVisitor.java
+++
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingRuleSQLStatementVisitor.java
@@ -20,22 +20,22 @@ package
org.apache.shardingsphere.readwritesplitting.distsql.parser.core;
import org.antlr.v4.runtime.RuleContext;
import org.antlr.v4.runtime.tree.TerminalNode;
import
org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementBaseVisitor;
+import
org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.AlgorithmDefinitionContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.AlgorithmPropertyContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.AlterReadwriteSplittingRuleContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.CreateReadwriteSplittingRuleContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.DropReadwriteSplittingRuleContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.DynamicReadwriteSplittingRuleDefinitionContext;
-import
org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.FunctionDefinitionContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.ReadwriteSplittingRuleDefinitionContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.SchemaNameContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.ShowReadwriteSplittingRulesContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.StaticReadwriteSplittingRuleDefinitionContext;
-import org.apache.shardingsphere.distsql.parser.segment.FunctionSegment;
-import
org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.segment.ReadwriteSplittingRuleSegment;
+import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import
org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.AlterReadwriteSplittingRuleStatement;
import
org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.CreateReadwriteSplittingRuleStatement;
import
org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.DropReadwriteSplittingRuleStatement;
import
org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.ShowReadwriteSplittingRulesStatement;
+import
org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.segment.ReadwriteSplittingRuleSegment;
import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.SchemaSegment;
@@ -56,16 +56,30 @@ public final class
ReadwriteSplittingRuleSQLStatementVisitor extends ReadwriteSp
}
@Override
+ public ASTNode visitAlterReadwriteSplittingRule(final
AlterReadwriteSplittingRuleContext ctx) {
+ return new
AlterReadwriteSplittingRuleStatement(ctx.readwriteSplittingRuleDefinition().stream().map(each
-> (ReadwriteSplittingRuleSegment) visit(each)).collect(Collectors.toList()));
+ }
+
+ @Override
+ public ASTNode visitDropReadwriteSplittingRule(final
DropReadwriteSplittingRuleContext ctx) {
+ return new
DropReadwriteSplittingRuleStatement(ctx.IDENTIFIER().stream().map(TerminalNode::getText).collect(Collectors.toList()));
+ }
+
+ @Override
+ public ASTNode visitShowReadwriteSplittingRules(final
ShowReadwriteSplittingRulesContext ctx) {
+ return new
ShowReadwriteSplittingRulesStatement(Objects.nonNull(ctx.schemaName()) ?
(SchemaSegment) visit(ctx.schemaName()) : null);
+ }
+
+ @Override
public ASTNode visitReadwriteSplittingRuleDefinition(final
ReadwriteSplittingRuleDefinitionContext ctx) {
ReadwriteSplittingRuleSegment result = (ReadwriteSplittingRuleSegment)
(null != ctx.dynamicReadwriteSplittingRuleDefinition()
? visit(ctx.dynamicReadwriteSplittingRuleDefinition()) :
visit(ctx.staticReadwriteSplittingRuleDefinition()));
Properties props = new Properties();
- if (null != ctx.functionDefinition().algorithmProperties()) {
- ctx.functionDefinition().algorithmProperties().algorithmProperty()
- .forEach(each -> props.setProperty(each.key.getText(),
each.value.getText()));
+ if (null != ctx.algorithmDefinition().algorithmProperties()) {
+
ctx.algorithmDefinition().algorithmProperties().algorithmProperty().forEach(each
-> props.setProperty(each.key.getText(), each.value.getText()));
}
result.setName(ctx.ruleName().getText());
-
result.setLoadBalancer(ctx.functionDefinition().functionName().getText());
+
result.setLoadBalancer(ctx.algorithmDefinition().algorithmName().getText());
result.setProps(props);
return result;
}
@@ -86,31 +100,16 @@ public final class
ReadwriteSplittingRuleSQLStatementVisitor extends ReadwriteSp
}
@Override
- public ASTNode visitAlterReadwriteSplittingRule(final
AlterReadwriteSplittingRuleContext ctx) {
- return new
AlterReadwriteSplittingRuleStatement(ctx.readwriteSplittingRuleDefinition().stream().map(each
-> (ReadwriteSplittingRuleSegment) visit(each)).collect(Collectors.toList()));
- }
-
- @Override
- public ASTNode visitDropReadwriteSplittingRule(final
DropReadwriteSplittingRuleContext ctx) {
- return new
DropReadwriteSplittingRuleStatement(ctx.IDENTIFIER().stream().map(TerminalNode::getText).collect(Collectors.toList()));
- }
-
- @Override
- public ASTNode visitShowReadwriteSplittingRules(final
ShowReadwriteSplittingRulesContext ctx) {
- return new
ShowReadwriteSplittingRulesStatement(Objects.nonNull(ctx.schemaName()) ?
(SchemaSegment) visit(ctx.schemaName()) : null);
- }
-
- @Override
public ASTNode visitSchemaName(final SchemaNameContext ctx) {
return new SchemaSegment(ctx.getStart().getStartIndex(),
ctx.getStop().getStopIndex(), new IdentifierValue(ctx.getText()));
}
@Override
- public ASTNode visitFunctionDefinition(final FunctionDefinitionContext
ctx) {
- return new FunctionSegment(ctx.functionName().getText(),
getAlgorithmProperties(ctx));
+ public ASTNode visitAlgorithmDefinition(final AlgorithmDefinitionContext
ctx) {
+ return new AlgorithmSegment(ctx.algorithmName().getText(),
getAlgorithmProperties(ctx));
}
- private Properties getAlgorithmProperties(final FunctionDefinitionContext
ctx) {
+ private Properties getAlgorithmProperties(final AlgorithmDefinitionContext
ctx) {
Properties result = new Properties();
if (null == ctx.algorithmProperties()) {
return result;
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/converter/ShardingRuleStatementConverter.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/converter/ShardingRuleStatementConverter.java
index 55b7981..961e6c6 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/converter/ShardingRuleStatementConverter.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/converter/ShardingRuleStatementConverter.java
@@ -21,7 +21,7 @@ import com.google.common.base.Joiner;
import com.google.common.base.Strings;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.segment.FunctionSegment;
+import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.segment.TableRuleSegment;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.segment.ShardingBindingTableRuleSegment;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.AlterShardingBindingTableRulesStatement;
@@ -97,21 +97,21 @@ public final class ShardingRuleStatementConverter {
for (TableRuleSegment each : tableRuleSegments) {
if (null != each.getTableStrategy()) {
result.getShardingAlgorithms().put(getAlgorithmName(each.getLogicTable(),
- each.getTableStrategy().getAlgorithmName()),
createAlgorithmConfiguration(each.getTableStrategy()));
+ each.getTableStrategy().getName()),
createAlgorithmConfiguration(each.getTableStrategy()));
result.getAutoTables().put(each.getLogicTable(),
createAutoTableRuleConfiguration(each));
}
if (null != each.getKeyGenerateStrategy()) {
result.getKeyGenerators().put(getKeyGeneratorName(each.getLogicTable(),
- each.getKeyGenerateStrategy().getAlgorithmName()),
createAlgorithmConfiguration(each.getKeyGenerateStrategy()));
+ each.getKeyGenerateStrategy().getName()),
createAlgorithmConfiguration(each.getKeyGenerateStrategy()));
}
}
return result;
}
- private static YamlShardingSphereAlgorithmConfiguration
createAlgorithmConfiguration(final FunctionSegment segment) {
+ private static YamlShardingSphereAlgorithmConfiguration
createAlgorithmConfiguration(final AlgorithmSegment segment) {
YamlShardingSphereAlgorithmConfiguration result = new
YamlShardingSphereAlgorithmConfiguration();
- result.setType(segment.getAlgorithmName());
- result.setProps(segment.getAlgorithmProps());
+ result.setType(segment.getName());
+ result.setProps(segment.getProps());
return result;
}
@@ -130,7 +130,7 @@ public final class ShardingRuleStatementConverter {
YamlShardingStrategyConfiguration result = new
YamlShardingStrategyConfiguration();
YamlStandardShardingStrategyConfiguration standard = new
YamlStandardShardingStrategyConfiguration();
standard.setShardingColumn(segment.getTableStrategyColumn());
-
standard.setShardingAlgorithmName(getAlgorithmName(segment.getLogicTable(),
segment.getTableStrategy().getAlgorithmName()));
+
standard.setShardingAlgorithmName(getAlgorithmName(segment.getLogicTable(),
segment.getTableStrategy().getName()));
result.setStandard(standard);
return result;
}
@@ -138,7 +138,7 @@ public final class ShardingRuleStatementConverter {
private static YamlKeyGenerateStrategyConfiguration
createKeyGenerateStrategyConfiguration(final TableRuleSegment segment) {
YamlKeyGenerateStrategyConfiguration result = new
YamlKeyGenerateStrategyConfiguration();
result.setColumn(segment.getKeyGenerateStrategyColumn());
-
result.setKeyGeneratorName(getKeyGeneratorName(segment.getLogicTable(),
segment.getKeyGenerateStrategy().getAlgorithmName()));
+
result.setKeyGeneratorName(getKeyGeneratorName(segment.getLogicTable(),
segment.getKeyGenerateStrategy().getName()));
return result;
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/converter/ShardingRuleStatementConverterTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/converter/ShardingRuleStatementConverterTest.java
index 589f3fc..c549c5b 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/converter/ShardingRuleStatementConverterTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/converter/ShardingRuleStatementConverterTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.sharding.converter;
-import org.apache.shardingsphere.distsql.parser.segment.FunctionSegment;
+import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.segment.TableRuleSegment;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.CreateShardingTableRuleStatement;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
@@ -49,7 +49,7 @@ public final class ShardingRuleStatementConverterTest {
segment.setTableStrategyColumn("order_id");
Properties props = new Properties();
props.setProperty("sharding_count", "2");
- segment.setTableStrategy(new FunctionSegment("MOD", props));
+ segment.setTableStrategy(new AlgorithmSegment("MOD", props));
sqlStatement = new
CreateShardingTableRuleStatement(Collections.singleton(segment));
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/src/main/antlr4/imports/sharding/RDLStatement.g4
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/src/main/antlr4/imports/sharding/RDLStatement.g4
index 3c4234e..02e9f1a 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/src/main/antlr4/imports/sharding/RDLStatement.g4
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/src/main/antlr4/imports/sharding/RDLStatement.g4
@@ -56,7 +56,7 @@ dropShardingBroadcastTableRules
;
shardingTableRuleDefinition
- : tableName LP resources (COMMA shardingColumn)? (COMMA
functionDefinition)? (COMMA keyGenerateStrategy)? RP
+ : tableName LP resources (COMMA shardingColumn)? (COMMA
algorithmDefinition)? (COMMA keyGenerateStrategy)? RP
;
resources
@@ -68,7 +68,7 @@ shardingColumn
;
keyGenerateStrategy
- : GENERATED_KEY LP COLUMN EQ columnName COMMA functionDefinition RP
+ : GENERATED_KEY LP COLUMN EQ columnName COMMA algorithmDefinition RP
;
tableName
@@ -79,11 +79,15 @@ columnName
: IDENTIFIER
;
-functionDefinition
- : TYPE LP NAME EQ functionName (COMMA PROPERTIES LP algorithmProperties?
RP)? RP
+bindTableRulesDefinition
+ : LP tableName (COMMA tableName)* RP
+ ;
+
+algorithmDefinition
+ : TYPE LP NAME EQ algorithmName (COMMA PROPERTIES LP algorithmProperties?
RP)? RP
;
-functionName
+algorithmName
: IDENTIFIER
;
@@ -94,7 +98,3 @@ algorithmProperties
algorithmProperty
: key=(IDENTIFIER | STRING) EQ value=(NUMBER | INT | STRING)
;
-
-bindTableRulesDefinition
- : LP tableName (COMMA tableName)* RP
- ;
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingRuleSQLStatementVisitor.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingRuleSQLStatementVisitor.java
index 0ead4e4..4e8b8a5 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingRuleSQLStatementVisitor.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingRuleSQLStatementVisitor.java
@@ -21,6 +21,7 @@ import com.google.common.base.Joiner;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.TerminalNode;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingRuleStatementBaseVisitor;
+import
org.apache.shardingsphere.distsql.parser.autogen.ShardingRuleStatementParser.AlgorithmDefinitionContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingRuleStatementParser.AlgorithmPropertyContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingRuleStatementParser.AlterShardingBindingTableRulesContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingRuleStatementParser.AlterShardingBroadcastTableRulesContext;
@@ -32,16 +33,13 @@ import
org.apache.shardingsphere.distsql.parser.autogen.ShardingRuleStatementPar
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingRuleStatementParser.DropShardingBindingTableRulesContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingRuleStatementParser.DropShardingBroadcastTableRulesContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingRuleStatementParser.DropShardingTableRuleContext;
-import
org.apache.shardingsphere.distsql.parser.autogen.ShardingRuleStatementParser.FunctionDefinitionContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingRuleStatementParser.SchemaNameContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingRuleStatementParser.ShardingTableRuleDefinitionContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingRuleStatementParser.ShowShardingBindingTableRulesContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingRuleStatementParser.ShowShardingBroadcastTableRulesContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingRuleStatementParser.ShowShardingTableRulesContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingRuleStatementParser.TableNameContext;
-import org.apache.shardingsphere.distsql.parser.segment.FunctionSegment;
-import
org.apache.shardingsphere.sharding.distsql.parser.statement.segment.TableRuleSegment;
-import
org.apache.shardingsphere.sharding.distsql.parser.statement.segment.ShardingBindingTableRuleSegment;
+import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.AlterShardingBindingTableRulesStatement;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.AlterShardingBroadcastTableRulesStatement;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.AlterShardingTableRuleStatement;
@@ -54,6 +52,8 @@ import
org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingT
import
org.apache.shardingsphere.sharding.distsql.parser.statement.ShowShardingBindingTableRulesStatement;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.ShowShardingBroadcastTableRulesStatement;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.ShowShardingTableRulesStatement;
+import
org.apache.shardingsphere.sharding.distsql.parser.statement.segment.ShardingBindingTableRuleSegment;
+import
org.apache.shardingsphere.sharding.distsql.parser.statement.segment.TableRuleSegment;
import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.SchemaSegment;
@@ -134,6 +134,11 @@ public final class ShardingRuleSQLStatementVisitor extends
ShardingRuleStatement
}
@Override
+ public ASTNode visitShowShardingTableRules(final
ShowShardingTableRulesContext ctx) {
+ return new ShowShardingTableRulesStatement(null == ctx.tableRule() ?
null : ctx.tableRule().tableName().getText(), null == ctx.schemaName() ? null :
(SchemaSegment) visit(ctx.schemaName()));
+ }
+
+ @Override
public ASTNode visitShardingTableRuleDefinition(final
ShardingTableRuleDefinitionContext ctx) {
TableRuleSegment result = new TableRuleSegment();
result.setLogicTable(ctx.tableName().getText());
@@ -144,23 +149,23 @@ public final class ShardingRuleSQLStatementVisitor
extends ShardingRuleStatement
}
}
result.setDataSources(dataSources);
- if (null != ctx.functionDefinition()) {
- result.setTableStrategy((FunctionSegment)
visit(ctx.functionDefinition()));
+ if (null != ctx.algorithmDefinition()) {
+ result.setTableStrategy((AlgorithmSegment)
visit(ctx.algorithmDefinition()));
result.setTableStrategyColumn(ctx.shardingColumn().columnName().getText());
}
if (null != ctx.keyGenerateStrategy()) {
- result.setKeyGenerateStrategy((FunctionSegment)
visit(ctx.keyGenerateStrategy().functionDefinition()));
+ result.setKeyGenerateStrategy((AlgorithmSegment)
visit(ctx.keyGenerateStrategy().algorithmDefinition()));
result.setKeyGenerateStrategyColumn(ctx.keyGenerateStrategy().columnName().getText());
}
return result;
}
@Override
- public ASTNode visitFunctionDefinition(final FunctionDefinitionContext
ctx) {
- return new FunctionSegment(ctx.functionName().getText(),
getAlgorithmProperties(ctx));
+ public ASTNode visitAlgorithmDefinition(final AlgorithmDefinitionContext
ctx) {
+ return new AlgorithmSegment(ctx.algorithmName().getText(),
getAlgorithmProperties(ctx));
}
- private Properties getAlgorithmProperties(final FunctionDefinitionContext
ctx) {
+ private Properties getAlgorithmProperties(final AlgorithmDefinitionContext
ctx) {
Properties result = new Properties();
if (null == ctx.algorithmProperties()) {
return result;
@@ -178,17 +183,11 @@ public final class ShardingRuleSQLStatementVisitor
extends ShardingRuleStatement
@Override
public ASTNode visitShowShardingBindingTableRules(final
ShowShardingBindingTableRulesContext ctx) {
- return new
ShowShardingBindingTableRulesStatement(Objects.nonNull(ctx.schemaName()) ?
(SchemaSegment) visit(ctx.schemaName()) : null);
+ return new ShowShardingBindingTableRulesStatement(null ==
ctx.schemaName() ? null : (SchemaSegment) visit(ctx.schemaName()));
}
@Override
public ASTNode visitSchemaName(final SchemaNameContext ctx) {
return new SchemaSegment(ctx.getStart().getStartIndex(),
ctx.getStop().getStopIndex(), new IdentifierValue(ctx.getText()));
}
-
- @Override
- public ASTNode visitShowShardingTableRules(final
ShowShardingTableRulesContext ctx) {
- return new
ShowShardingTableRulesStatement(Objects.nonNull(ctx.tableRule()) ?
ctx.tableRule().tableName().getText() : null,
- Objects.nonNull(ctx.schemaName()) ? (SchemaSegment)
visit(ctx.schemaName()) : null);
- }
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/statement/segment/TableRuleSegment.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/statement/segment/TableRuleSegment.java
index 6bb26b4..83b01ce 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/statement/segment/TableRuleSegment.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/statement/segment/TableRuleSegment.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.sharding.distsql.parser.statement.segment;
import lombok.Getter;
import lombok.Setter;
-import org.apache.shardingsphere.distsql.parser.segment.FunctionSegment;
+import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
import java.util.Collection;
@@ -39,7 +39,7 @@ public final class TableRuleSegment implements ASTNode {
private String keyGenerateStrategyColumn;
- private FunctionSegment tableStrategy;
+ private AlgorithmSegment tableStrategy;
- private FunctionSegment keyGenerateStrategy;
+ private AlgorithmSegment keyGenerateStrategy;
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/src/test/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingRuleStatementParserEngineTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/src/test/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingRuleStatementParserEngineTest.java
index 5db4b06..dc2efa0 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/src/test/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingRuleStatementParserEngineTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/src/test/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingRuleStatementParserEngineTest.java
@@ -96,11 +96,11 @@ public final class ShardingRuleStatementParserEngineTest {
assertThat(tableRuleSegment.getLogicTable(), is("t_order"));
assertTrue(tableRuleSegment.getDataSources().containsAll(Arrays.asList("ms_group_0",
"ms_group_1")));
assertThat(tableRuleSegment.getTableStrategyColumn(), is("order_id"));
-
assertThat(tableRuleSegment.getKeyGenerateStrategy().getAlgorithmName(),
is("snowflake"));
-
assertThat(tableRuleSegment.getKeyGenerateStrategy().getAlgorithmProps().getProperty("worker-id"),
is("123"));
+ assertThat(tableRuleSegment.getKeyGenerateStrategy().getName(),
is("snowflake"));
+
assertThat(tableRuleSegment.getKeyGenerateStrategy().getProps().getProperty("worker-id"),
is("123"));
assertThat(tableRuleSegment.getKeyGenerateStrategyColumn(),
is("another_id"));
- assertThat(tableRuleSegment.getTableStrategy().getAlgorithmName(),
is("hash_mod"));
-
assertThat(tableRuleSegment.getTableStrategy().getAlgorithmProps().getProperty("sharding-count"),
is("4"));
+ assertThat(tableRuleSegment.getTableStrategy().getName(),
is("hash_mod"));
+
assertThat(tableRuleSegment.getTableStrategy().getProps().getProperty("sharding-count"),
is("4"));
}
@Test
@@ -132,11 +132,11 @@ public final class ShardingRuleStatementParserEngineTest {
assertThat(tableRuleSegment.getLogicTable(), is("t_order"));
assertTrue(tableRuleSegment.getDataSources().containsAll(Arrays.asList("ms_group_0",
"ms_group_1")));
assertThat(tableRuleSegment.getTableStrategyColumn(), is("order_id"));
-
assertThat(tableRuleSegment.getKeyGenerateStrategy().getAlgorithmName(),
is("snowflake"));
-
assertThat(tableRuleSegment.getKeyGenerateStrategy().getAlgorithmProps().getProperty("worker-id"),
is("123"));
+ assertThat(tableRuleSegment.getKeyGenerateStrategy().getName(),
is("snowflake"));
+
assertThat(tableRuleSegment.getKeyGenerateStrategy().getProps().getProperty("worker-id"),
is("123"));
assertThat(tableRuleSegment.getKeyGenerateStrategyColumn(),
is("another_id"));
- assertThat(tableRuleSegment.getTableStrategy().getAlgorithmName(),
is("hash_mod"));
-
assertThat(tableRuleSegment.getTableStrategy().getAlgorithmProps().getProperty("sharding-count"),
is("4"));
+ assertThat(tableRuleSegment.getTableStrategy().getName(),
is("hash_mod"));
+
assertThat(tableRuleSegment.getTableStrategy().getProps().getProperty("sharding-count"),
is("4"));
}
@Test
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AlterEncryptRuleBackendHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AlterEncryptRuleBackendHandler.java
index 55f1443..36aa7f5 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AlterEncryptRuleBackendHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AlterEncryptRuleBackendHandler.java
@@ -101,7 +101,7 @@ public final class AlterEncryptRuleBackendHandler extends
RDLBackendHandler<Alte
private void checkEncryptors(final AlterEncryptRuleStatement sqlStatement)
{
Collection<String> encryptors = new LinkedHashSet<>();
sqlStatement.getRules().forEach(each ->
encryptors.addAll(each.getColumns().stream()
- .map(column ->
column.getEncryptor().getAlgorithmName()).collect(Collectors.toSet())));
+ .map(column ->
column.getEncryptor().getName()).collect(Collectors.toSet())));
Collection<String> invalidEncryptors = encryptors.stream().filter(each
-> !TypedSPIRegistry.findRegisteredService(EncryptAlgorithm.class, each, new
Properties()).isPresent())
.collect(Collectors.toList());
if (!invalidEncryptors.isEmpty()) {
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AlterShardingTableRuleBackendHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AlterShardingTableRuleBackendHandler.java
index ae0c731..eb2d7dd 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AlterShardingTableRuleBackendHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AlterShardingTableRuleBackendHandler.java
@@ -78,7 +78,7 @@ public final class AlterShardingTableRuleBackendHandler
extends RDLBackendHandle
if (!notExistTables.isEmpty()) {
throw new ShardingTableRuleNotExistedException(schemaName,
notExistTables);
}
- Collection<String> invalidTableAlgorithms =
sqlStatement.getRules().stream().map(each ->
each.getTableStrategy().getAlgorithmName()).distinct()
+ Collection<String> invalidTableAlgorithms =
sqlStatement.getRules().stream().map(each ->
each.getTableStrategy().getName()).distinct()
.filter(each ->
!TypedSPIRegistry.findRegisteredService(ShardingAlgorithm.class, each, new
Properties()).isPresent())
.collect(Collectors.toList());
if (!invalidTableAlgorithms.isEmpty()) {
@@ -144,6 +144,6 @@ public final class AlterShardingTableRuleBackendHandler
extends RDLBackendHandle
private Collection<String> getKeyGenerators(final
AlterShardingTableRuleStatement sqlStatement) {
return sqlStatement.getRules().stream().filter(each ->
Objects.nonNull(each.getKeyGenerateStrategy()))
- .map(each ->
each.getKeyGenerateStrategy().getAlgorithmName()).collect(Collectors.toSet());
+ .map(each ->
each.getKeyGenerateStrategy().getName()).collect(Collectors.toSet());
}
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/CreateEncryptRuleBackendHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/CreateEncryptRuleBackendHandler.java
index 8dbb3e0..e8ff769 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/CreateEncryptRuleBackendHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/CreateEncryptRuleBackendHandler.java
@@ -90,7 +90,7 @@ public final class CreateEncryptRuleBackendHandler extends
RDLBackendHandler<Cre
private void checkEncryptors(final CreateEncryptRuleStatement
sqlStatement) {
Collection<String> encryptors = new LinkedHashSet<>();
sqlStatement.getRules().forEach(each ->
encryptors.addAll(each.getColumns().stream()
- .map(column ->
column.getEncryptor().getAlgorithmName()).collect(Collectors.toSet())));
+ .map(column ->
column.getEncryptor().getName()).collect(Collectors.toSet())));
Collection<String> invalidEncryptors = encryptors.stream().filter(
each ->
!TypedSPIRegistry.findRegisteredService(EncryptAlgorithm.class, each, new
Properties()).isPresent()).collect(Collectors.toList());
if (!invalidEncryptors.isEmpty()) {
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/CreateShardingTableRuleBackendHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/CreateShardingTableRuleBackendHandler.java
index 0716776..34c8638 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/CreateShardingTableRuleBackendHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/CreateShardingTableRuleBackendHandler.java
@@ -75,7 +75,7 @@ public final class CreateShardingTableRuleBackendHandler
extends RDLBackendHandl
if (!duplicateTableNames.isEmpty()) {
throw new DuplicateTablesException(duplicateTableNames);
}
- Collection<String> invalidTableAlgorithms =
sqlStatement.getRules().stream().map(each ->
each.getTableStrategy().getAlgorithmName()).distinct()
+ Collection<String> invalidTableAlgorithms =
sqlStatement.getRules().stream().map(each ->
each.getTableStrategy().getName()).distinct()
.filter(each ->
!TypedSPIRegistry.findRegisteredService(ShardingAlgorithm.class, each, new
Properties()).isPresent())
.collect(Collectors.toList());
if (!invalidTableAlgorithms.isEmpty()) {
@@ -126,6 +126,6 @@ public final class CreateShardingTableRuleBackendHandler
extends RDLBackendHandl
private Collection<String> getKeyGenerators(final
CreateShardingTableRuleStatement sqlStatement) {
return sqlStatement.getRules().stream().filter(each ->
Objects.nonNull(each.getKeyGenerateStrategy()))
- .map(each ->
each.getKeyGenerateStrategy().getAlgorithmName()).collect(Collectors.toSet());
+ .map(each ->
each.getKeyGenerateStrategy().getName()).collect(Collectors.toSet());
}
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AlterEncryptRuleBackendHandlerTest.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AlterEncryptRuleBackendHandlerTest.java
index aec9f62..97d3144 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AlterEncryptRuleBackendHandlerTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AlterEncryptRuleBackendHandlerTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.proxy.backend.text.distsql.rdl.impl;
-import org.apache.shardingsphere.distsql.parser.segment.FunctionSegment;
+import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import
org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
import
org.apache.shardingsphere.encrypt.distsql.parser.statement.AlterEncryptRuleStatement;
@@ -126,7 +126,7 @@ public final class AlterEncryptRuleBackendHandlerTest {
result.setName("user_id");
result.setPlainColumn("user_plain");
result.setCipherColumn("user_cipher");
- result.setEncryptor(new FunctionSegment(encryptorName, new
Properties()));
+ result.setEncryptor(new AlgorithmSegment(encryptorName, new
Properties()));
return Collections.singleton(result);
}
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AlterShardingTableRuleBackendHandlerTest.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AlterShardingTableRuleBackendHandlerTest.java
index 8e85ba2..2f7dc74 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AlterShardingTableRuleBackendHandlerTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/AlterShardingTableRuleBackendHandlerTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.proxy.backend.text.distsql.rdl.impl;
-import org.apache.shardingsphere.distsql.parser.segment.FunctionSegment;
+import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.segment.TableRuleSegment;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.AlterShardingTableRuleStatement;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
@@ -101,7 +101,7 @@ public final class AlterShardingTableRuleBackendHandlerTest
{
public void assertExecute() {
TableRuleSegment tableRuleSegment = new TableRuleSegment();
tableRuleSegment.setLogicTable("t_order");
- tableRuleSegment.setTableStrategy(new FunctionSegment("hash_mod", new
Properties()));
+ tableRuleSegment.setTableStrategy(new AlgorithmSegment("hash_mod", new
Properties()));
tableRuleSegment.setDataSources(Collections.singleton("ds_0"));
tableRuleSegment.setTableStrategyColumn("order_id");
when(ruleMetaData.getConfigurations()).thenReturn(buildShardingConfigurations());
@@ -140,7 +140,7 @@ public final class AlterShardingTableRuleBackendHandlerTest
{
TableRuleSegment tableRuleSegment = new TableRuleSegment();
tableRuleSegment.setLogicTable("t_order_item");
tableRuleSegment.setDataSources(Collections.emptyList());
- tableRuleSegment.setTableStrategy(new
FunctionSegment("algorithm-not-exist", new Properties()));
+ tableRuleSegment.setTableStrategy(new
AlgorithmSegment("algorithm-not-exist", new Properties()));
when(sqlStatement.getRules()).thenReturn(Collections.singleton(tableRuleSegment));
when(ruleMetaData.getConfigurations()).thenReturn(buildShardingConfigurations());
handler.execute("test", sqlStatement);
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/CreateEncryptRuleBackendHandlerTest.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/CreateEncryptRuleBackendHandlerTest.java
index 7ace988..8d3e4bc 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/CreateEncryptRuleBackendHandlerTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/CreateEncryptRuleBackendHandlerTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.backend.text.distsql.rdl.impl;
import com.google.common.collect.Maps;
-import org.apache.shardingsphere.distsql.parser.segment.FunctionSegment;
+import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import
org.apache.shardingsphere.encrypt.distsql.parser.statement.segment.EncryptColumnSegment;
import
org.apache.shardingsphere.encrypt.distsql.parser.statement.segment.EncryptRuleSegment;
import
org.apache.shardingsphere.encrypt.distsql.parser.statement.CreateEncryptRuleStatement;
@@ -114,7 +114,7 @@ public final class CreateEncryptRuleBackendHandlerTest {
result.setName("user_id");
result.setPlainColumn("user_plain");
result.setCipherColumn("user_cipher");
- result.setEncryptor(new FunctionSegment(encryptorName, new
Properties()));
+ result.setEncryptor(new AlgorithmSegment(encryptorName, new
Properties()));
return Collections.singleton(result);
}
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/CreateShardingTableRuleBackendHandlerTest.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/CreateShardingTableRuleBackendHandlerTest.java
index 9359861..34df58a 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/CreateShardingTableRuleBackendHandlerTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/CreateShardingTableRuleBackendHandlerTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.proxy.backend.text.distsql.rdl.impl;
-import org.apache.shardingsphere.distsql.parser.segment.FunctionSegment;
+import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.segment.TableRuleSegment;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.CreateShardingTableRuleStatement;
import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
@@ -87,7 +87,7 @@ public final class CreateShardingTableRuleBackendHandlerTest {
TableRuleSegment tableRuleSegment = new TableRuleSegment();
tableRuleSegment.setLogicTable("t_order_item");
tableRuleSegment.setDataSources(Collections.emptyList());
- tableRuleSegment.setTableStrategy(new FunctionSegment("hash_mod", new
Properties()));
+ tableRuleSegment.setTableStrategy(new AlgorithmSegment("hash_mod", new
Properties()));
ResponseHeader responseHeader = handler.execute("test", sqlStatement);
assertNotNull(responseHeader);
assertTrue(responseHeader instanceof UpdateResponseHeader);
@@ -116,7 +116,7 @@ public final class
CreateShardingTableRuleBackendHandlerTest {
TableRuleSegment tableRuleSegment = new TableRuleSegment();
tableRuleSegment.setLogicTable("t_order_item");
tableRuleSegment.setDataSources(Collections.emptyList());
- tableRuleSegment.setTableStrategy(new
FunctionSegment("algorithm-not-exist", new Properties()));
+ tableRuleSegment.setTableStrategy(new
AlgorithmSegment("algorithm-not-exist", new Properties()));
when(sqlStatement.getRules()).thenReturn(Collections.singleton(tableRuleSegment));
handler.execute("test", sqlStatement);
}