This is an automated email from the ASF dual-hosted git repository.

chengzhang 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 426593fef6f Refactor InvalidAlgorithmConfigurationException (#30697)
426593fef6f is described below

commit 426593fef6f8ac62cdcb3f95c5e34500b4250a6c
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Mar 30 17:42:18 2024 +0800

    Refactor InvalidAlgorithmConfigurationException (#30697)
    
    * Refactor InvalidAlgorithmConfigurationException
    
    * Refactor InvalidAlgorithmConfigurationException
    
    * Refactor InvalidAlgorithmConfigurationException
    
    * Refactor InvalidAlgorithmConfigurationException
    
    * Refactor InvalidAlgorithmConfigurationException
---
 .../user-manual/error-code/sql-error-code.cn.md    |  4 +--
 .../user-manual/error-code/sql-error-code.en.md    |  4 +--
 .../handler/update/CreateEncryptRuleExecutor.java  | 14 ++++----
 .../checker/ShardingTableRuleStatementChecker.java | 42 ++++++++++------------
 .../checker/ShardingRuleStatementCheckerTest.java  | 17 ++++-----
 .../CreateShardingTableRuleExecutorTest.java       |  4 +--
 .../exception/type/AlgorithmInUsedException.java   |  2 +-
 .../InvalidAlgorithmConfigurationException.java    |  8 ++---
 8 files changed, 44 insertions(+), 51 deletions(-)

diff --git a/docs/document/content/user-manual/error-code/sql-error-code.cn.md 
b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
index c52024c8a40..e7e604cf31b 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.cn.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
@@ -30,8 +30,8 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 | 44000     | 10090       | Algorithm '%s.'%s' initialization failed, reason 
is: %s.                       |
 | 44000     | 10091       | '%s' algorithm on %s is required.                  
                            |
 | 42S02     | 10092       | '%s' algorithm '%s' on %s is unregistered.         
                            |
-| 44000     | 10093       | Invalid %s algorithm '%s', %s.                     
                            |
-| 44000     | 10094       | %s algorithms '%s' in database '%s' are still in 
used.                         |
+| 44000     | 10093       | %s algorithms '%s' in database '%s' are still in 
used.                         |
+| 44000     | 10094       | Invalid %s algorithm configuration '%s'.           
                            |
 | HY000     | 10099       | Algorithm '%s.%s' execute failed, reason is: %s.   
                            |
 
 ### 数据
diff --git a/docs/document/content/user-manual/error-code/sql-error-code.en.md 
b/docs/document/content/user-manual/error-code/sql-error-code.en.md
index bc2096cf890..a62063b4ea8 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.en.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.en.md
@@ -34,8 +34,8 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 | 44000     | 10090       | Algorithm '%s.'%s' initialization failed, reason 
is: %s.                       |
 | 44000     | 10091       | '%s' algorithm on %s is required.                  
                            |
 | 42S02     | 10092       | '%s' algorithm '%s' on %s is unregistered.         
                            |
-| 44000     | 10093       | Invalid %s algorithm '%s', %s.                     
                            |
-| 44000     | 10094       | %s algorithms '%s' in database '%s' are still in 
used.                         |
+| 44000     | 10093       | %s algorithms '%s' in database '%s' are still in 
used.                         |
+| 44000     | 10094       | Invalid %s algorithm configuration '%s'.           
                            |
 | HY000     | 10099       | Algorithm '%s.%s' execute failed, reason is: %s.   
                            |
 
 ### Data
diff --git 
a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutor.java
 
b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutor.java
index 7c02b75262a..c86d8db4668 100644
--- 
a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutor.java
+++ 
b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutor.java
@@ -18,10 +18,6 @@
 package org.apache.shardingsphere.encrypt.distsql.handler.update;
 
 import lombok.Setter;
-import 
org.apache.shardingsphere.infra.algorithm.core.exception.type.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
-import 
org.apache.shardingsphere.infra.exception.rule.InvalidRuleConfigurationException;
-import 
org.apache.shardingsphere.infra.exception.storageunit.EmptyStorageUnitException;
 import 
org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
 import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
 import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
@@ -33,7 +29,11 @@ import 
org.apache.shardingsphere.encrypt.distsql.segment.EncryptRuleSegment;
 import 
org.apache.shardingsphere.encrypt.distsql.statement.CreateEncryptRuleStatement;
 import org.apache.shardingsphere.encrypt.rule.EncryptRule;
 import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import 
org.apache.shardingsphere.infra.algorithm.core.exception.type.AlgorithmInitializationException;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
+import 
org.apache.shardingsphere.infra.exception.rule.InvalidRuleConfigurationException;
+import 
org.apache.shardingsphere.infra.exception.storageunit.EmptyStorageUnitException;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
 
@@ -101,7 +101,7 @@ public final class CreateEncryptRuleExecutor implements 
DatabaseRuleCreateExecut
             return;
         }
         EncryptAlgorithm encryptAlgorithm = 
TypedSPILoader.getService(EncryptAlgorithm.class, 
itemSegment.getEncryptor().getName(), itemSegment.getEncryptor().getProps());
-        
ShardingSpherePreconditions.checkState(encryptAlgorithm.getMetaData().isSupportDecrypt(),
 () -> new InvalidAlgorithmConfigurationException("standard encrypt", 
encryptAlgorithm.getType()));
+        
ShardingSpherePreconditions.checkState(encryptAlgorithm.getMetaData().isSupportDecrypt(),
 () -> new AlgorithmInitializationException(encryptAlgorithm, "Can not support 
decrypt"));
     }
     
     private void checkLikeAlgorithmType(final EncryptColumnItemSegment 
itemSegment) {
@@ -109,7 +109,7 @@ public final class CreateEncryptRuleExecutor implements 
DatabaseRuleCreateExecut
             return;
         }
         EncryptAlgorithm encryptAlgorithm = 
TypedSPILoader.getService(EncryptAlgorithm.class, 
itemSegment.getEncryptor().getName(), itemSegment.getEncryptor().getProps());
-        
ShardingSpherePreconditions.checkState(encryptAlgorithm.getMetaData().isSupportLike(),
 () -> new InvalidAlgorithmConfigurationException("like encrypt", 
encryptAlgorithm.getType()));
+        
ShardingSpherePreconditions.checkState(encryptAlgorithm.getMetaData().isSupportLike(),
 () -> new AlgorithmInitializationException(encryptAlgorithm, "Can not support 
like"));
     }
     
     private void checkAssistedAlgorithmType(final EncryptColumnItemSegment 
itemSegment) {
@@ -118,7 +118,7 @@ public final class CreateEncryptRuleExecutor implements 
DatabaseRuleCreateExecut
         }
         EncryptAlgorithm encryptAlgorithm = 
TypedSPILoader.getService(EncryptAlgorithm.class, 
itemSegment.getEncryptor().getName(), itemSegment.getEncryptor().getProps());
         
ShardingSpherePreconditions.checkState(encryptAlgorithm.getMetaData().isSupportEquivalentFilter(),
-                () -> new InvalidAlgorithmConfigurationException("assisted 
encrypt", encryptAlgorithm.getType()));
+                () -> new AlgorithmInitializationException(encryptAlgorithm, 
"Can not support assist query"));
     }
     
     private void checkToBeCreatedEncryptors(final CreateEncryptRuleStatement 
sqlStatement) {
diff --git 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
index 82500e8155e..cf9bb407f92 100644
--- 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
+++ 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
@@ -21,15 +21,16 @@ import com.cedarsoftware.util.CaseInsensitiveSet;
 import com.google.common.base.Splitter;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
+import 
org.apache.shardingsphere.infra.algorithm.core.exception.type.AlgorithmInitializationException;
 import 
org.apache.shardingsphere.infra.algorithm.core.exception.type.InvalidAlgorithmConfigurationException;
+import 
org.apache.shardingsphere.infra.algorithm.keygen.core.KeyGenerateAlgorithm;
+import org.apache.shardingsphere.infra.datanode.DataNode;
+import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
 import 
org.apache.shardingsphere.infra.exception.rule.InvalidRuleConfigurationException;
 import 
org.apache.shardingsphere.infra.exception.rule.MissingRequiredRuleException;
 import 
org.apache.shardingsphere.infra.exception.storageunit.MissingRequiredStorageUnitsException;
-import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
-import 
org.apache.shardingsphere.infra.algorithm.keygen.core.KeyGenerateAlgorithm;
-import org.apache.shardingsphere.infra.datanode.DataNode;
-import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.rule.attribute.datasource.DataSourceMapperRuleAttribute;
@@ -147,7 +148,7 @@ public final class ShardingTableRuleStatementChecker {
         checkKeyGenerators(rules);
         checkAuditors(rules);
         
checkAutoTableRule(rules.stream().filter(AutoTableRuleSegment.class::isInstance).map(AutoTableRuleSegment.class::cast).collect(Collectors.toList()));
-        checkTableRule(databaseName, 
rules.stream().filter(TableRuleSegment.class::isInstance).map(TableRuleSegment.class::cast).collect(Collectors.toList()));
+        
checkTableRule(rules.stream().filter(TableRuleSegment.class::isInstance).map(TableRuleSegment.class::cast).collect(Collectors.toList()));
         if (!isCreated) {
             checkBindingTableRules(rules, currentRuleConfig);
         }
@@ -401,20 +402,17 @@ public final class ShardingTableRuleStatementChecker {
     
     private static void checkAutoTableShardingAlgorithms(final 
Collection<AutoTableRuleSegment> autoTableRules) {
         autoTableRules.forEach(each -> {
-            ShardingSpherePreconditions.checkState(TypedSPILoader.findService(
-                    ShardingAlgorithm.class, 
each.getShardingAlgorithmSegment().getName(), 
each.getShardingAlgorithmSegment().getProps()).isPresent(),
-                    () -> new 
InvalidAlgorithmConfigurationException("sharding", 
each.getShardingAlgorithmSegment().getName()));
             ShardingAlgorithm shardingAlgorithm = 
TypedSPILoader.getService(ShardingAlgorithm.class, 
each.getShardingAlgorithmSegment().getName(), 
each.getShardingAlgorithmSegment().getProps());
-            ShardingSpherePreconditions.checkState(shardingAlgorithm 
instanceof ShardingAutoTableAlgorithm, () -> new 
InvalidAlgorithmConfigurationException("sharding", shardingAlgorithm.getType(),
-                    String.format("auto sharding algorithm is required for 
rule `%s`", each.getLogicTable())));
+            ShardingSpherePreconditions.checkState(shardingAlgorithm 
instanceof ShardingAutoTableAlgorithm,
+                    () -> new 
AlgorithmInitializationException(shardingAlgorithm, "Auto sharding algorithm is 
required for table '%s'", each.getLogicTable()));
         });
     }
     
-    private static void checkTableRule(final String databaseName, final 
Collection<TableRuleSegment> tableRules) {
-        checkStrategy(databaseName, tableRules);
+    private static void checkTableRule(final Collection<TableRuleSegment> 
tableRules) {
+        checkStrategy(tableRules);
     }
     
-    private static void checkStrategy(final String databaseName, final 
Collection<TableRuleSegment> rules) {
+    private static void checkStrategy(final Collection<TableRuleSegment> 
rules) {
         for (TableRuleSegment each : rules) {
             Optional<ShardingStrategySegment> databaseStrategySegment = 
Optional.ofNullable(each.getDatabaseStrategySegment());
             if (databaseStrategySegment.isPresent()) {
@@ -424,7 +422,7 @@ public final class ShardingTableRuleStatementChecker {
                             () -> new 
InvalidShardingStrategyConfigurationException("database", 
databaseStrategySegment.get().getType(), "strategy does not match data nodes"));
                 } else {
                     AlgorithmSegment databaseShardingAlgorithm = 
databaseStrategySegment.get().getShardingAlgorithm();
-                    checkDatabaseShardingAlgorithm(databaseName, each, 
databaseShardingAlgorithm);
+                    checkDatabaseShardingAlgorithm(each, 
databaseShardingAlgorithm);
                 }
             }
             Optional<ShardingStrategySegment> tableStrategySegment = 
Optional.ofNullable(each.getTableStrategySegment());
@@ -435,32 +433,30 @@ public final class ShardingTableRuleStatementChecker {
                             () -> new 
InvalidShardingStrategyConfigurationException("table", 
tableStrategySegment.get().getType(), "strategy does not match data nodes"));
                 } else {
                     AlgorithmSegment tableShardingAlgorithm = 
tableStrategySegment.get().getShardingAlgorithm();
-                    checkTableShardingAlgorithm(databaseName, each, 
tableShardingAlgorithm);
+                    checkTableShardingAlgorithm(each, tableShardingAlgorithm);
                 }
             }
         }
     }
     
-    private static void checkDatabaseShardingAlgorithm(final String 
databaseName, final TableRuleSegment each, final AlgorithmSegment 
databaseShardingAlgorithm) {
+    private static void checkDatabaseShardingAlgorithm(final TableRuleSegment 
each, final AlgorithmSegment databaseShardingAlgorithm) {
         if (null != databaseShardingAlgorithm) {
             ShardingAlgorithm shardingAlgorithm = 
TypedSPILoader.getService(ShardingAlgorithm.class, 
databaseShardingAlgorithm.getName(), databaseShardingAlgorithm.getProps());
             ShardingSpherePreconditions.checkState(!(shardingAlgorithm 
instanceof ShardingAutoTableAlgorithm),
-                    () -> new 
InvalidAlgorithmConfigurationException("sharding", shardingAlgorithm.getType(),
-                            String.format("auto sharding algorithm cannot be 
used to create a table in Table mode `%s`", each.getLogicTable())));
+                    () -> new 
AlgorithmInitializationException(shardingAlgorithm, "Auto sharding algorithm 
can not be used to create a table in table '%s'", each.getLogicTable()));
         }
         
ShardingSpherePreconditions.checkState(isValidStrategy(each.getDatabaseStrategySegment()),
-                () -> new InvalidAlgorithmConfigurationException(databaseName, 
null == databaseShardingAlgorithm ? null : 
databaseShardingAlgorithm.getName()));
+                () -> new InvalidAlgorithmConfigurationException("sharding", 
null == databaseShardingAlgorithm ? null : 
databaseShardingAlgorithm.getName()));
     }
     
-    private static void checkTableShardingAlgorithm(final String databaseName, 
final TableRuleSegment each, final AlgorithmSegment tableShardingAlgorithm) {
+    private static void checkTableShardingAlgorithm(final TableRuleSegment 
each, final AlgorithmSegment tableShardingAlgorithm) {
         if (null != tableShardingAlgorithm) {
             ShardingAlgorithm shardingAlgorithm = 
TypedSPILoader.getService(ShardingAlgorithm.class, 
tableShardingAlgorithm.getName(), tableShardingAlgorithm.getProps());
             ShardingSpherePreconditions.checkState(!(shardingAlgorithm 
instanceof ShardingAutoTableAlgorithm),
-                    () -> new 
InvalidAlgorithmConfigurationException("sharding", shardingAlgorithm.getType(),
-                            String.format("auto sharding algorithm cannot be 
used to create a table in Table mode `%s`", each.getLogicTable())));
+                    () -> new 
AlgorithmInitializationException(shardingAlgorithm, "Auto sharding algorithm 
can not be used to create a table in table '%s'", each.getLogicTable()));
         }
         
ShardingSpherePreconditions.checkState(isValidStrategy(each.getTableStrategySegment()),
-                () -> new InvalidAlgorithmConfigurationException(databaseName, 
null == tableShardingAlgorithm ? null : tableShardingAlgorithm.getName()));
+                () -> new InvalidAlgorithmConfigurationException("sharding", 
null == tableShardingAlgorithm ? null : tableShardingAlgorithm.getName()));
     }
     
     private static boolean isValidStrategy(final ShardingStrategySegment 
shardingStrategySegment) {
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
index a3ad135ead7..ea0327aae7f 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
@@ -17,17 +17,17 @@
 
 package org.apache.shardingsphere.sharding.distsql.checker;
 
+import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
+import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
+import 
org.apache.shardingsphere.infra.algorithm.core.exception.type.AlgorithmInitializationException;
 import 
org.apache.shardingsphere.infra.algorithm.core.exception.type.InvalidAlgorithmConfigurationException;
-import 
org.apache.shardingsphere.sharding.exception.strategy.InvalidShardingStrategyConfigurationException;
+import 
org.apache.shardingsphere.infra.exception.core.external.sql.type.generic.UnsupportedSQLOperationException;
 import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
 import 
org.apache.shardingsphere.infra.exception.rule.MissingRequiredRuleException;
 import 
org.apache.shardingsphere.infra.exception.storageunit.MissingRequiredStorageUnitsException;
-import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
-import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
 import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
-import 
org.apache.shardingsphere.infra.exception.core.external.sql.type.generic.UnsupportedSQLOperationException;
 import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
@@ -43,6 +43,7 @@ import 
org.apache.shardingsphere.sharding.distsql.segment.strategy.ShardingStrat
 import 
org.apache.shardingsphere.sharding.distsql.segment.table.AbstractTableRuleSegment;
 import 
org.apache.shardingsphere.sharding.distsql.segment.table.AutoTableRuleSegment;
 import 
org.apache.shardingsphere.sharding.distsql.segment.table.TableRuleSegment;
+import 
org.apache.shardingsphere.sharding.exception.strategy.InvalidShardingStrategyConfigurationException;
 import org.apache.shardingsphere.test.fixture.jdbc.MockedDataSource;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
@@ -166,7 +167,7 @@ class ShardingRuleStatementCheckerTest {
         autoTableRuleSegment.setShardingColumn("product_id");
         autoTableRuleSegment.setShardingAlgorithmSegment(new 
AlgorithmSegment("not_exist", PropertiesBuilder.build(new Property("", ""))));
         Collection<AbstractTableRuleSegment> rules = 
Collections.singleton(autoTableRuleSegment);
-        assertThrows(InvalidAlgorithmConfigurationException.class, () -> 
ShardingTableRuleStatementChecker.checkCreation(database, rules, false, 
shardingRuleConfig));
+        assertThrows(ServiceProviderNotFoundException.class, () -> 
ShardingTableRuleStatementChecker.checkCreation(database, rules, false, 
shardingRuleConfig));
     }
     
     @Test
@@ -175,7 +176,7 @@ class ShardingRuleStatementCheckerTest {
         autoTableRuleSegment.setShardingColumn("product_id");
         autoTableRuleSegment.setShardingAlgorithmSegment(new 
AlgorithmSegment("complex", PropertiesBuilder.build(new Property("", ""))));
         Collection<AbstractTableRuleSegment> rules = 
Collections.singleton(autoTableRuleSegment);
-        assertThrows(InvalidAlgorithmConfigurationException.class, () -> 
ShardingTableRuleStatementChecker.checkCreation(database, rules, false, 
shardingRuleConfig));
+        assertThrows(ServiceProviderNotFoundException.class, () -> 
ShardingTableRuleStatementChecker.checkCreation(database, rules, false, 
shardingRuleConfig));
     }
     
     @Test
@@ -212,7 +213,7 @@ class ShardingRuleStatementCheckerTest {
         TableRuleSegment tableRuleSegment = new TableRuleSegment("t_product", 
Arrays.asList("ds_0", "ds_1"), keyGenerateStrategy, null);
         tableRuleSegment.setTableStrategySegment(new 
ShardingStrategySegment("standard", "user_id", databaseAlgorithmSegment));
         Collection<AbstractTableRuleSegment> rules = 
Collections.singleton(tableRuleSegment);
-        assertThrows(InvalidAlgorithmConfigurationException.class, () -> 
ShardingTableRuleStatementChecker.checkCreation(database, rules, false, 
shardingRuleConfig));
+        assertThrows(AlgorithmInitializationException.class, () -> 
ShardingTableRuleStatementChecker.checkCreation(database, rules, false, 
shardingRuleConfig));
     }
     
     @Test
@@ -257,7 +258,7 @@ class ShardingRuleStatementCheckerTest {
         AutoTableRuleSegment autoTableRuleSegment = new 
AutoTableRuleSegment("t_product", Arrays.asList("ds_0", "ds_1"));
         autoTableRuleSegment.setShardingAlgorithmSegment(new 
AlgorithmSegment("INLINE", PropertiesBuilder.build(new 
Property("algorithm-expression", "ds_${product_id % 2}"))));
         Collection<AbstractTableRuleSegment> rules = 
Collections.singleton(autoTableRuleSegment);
-        assertThrows(InvalidAlgorithmConfigurationException.class, () -> 
ShardingTableRuleStatementChecker.checkCreation(database, rules, false, 
shardingRuleConfig));
+        assertThrows(AlgorithmInitializationException.class, () -> 
ShardingTableRuleStatementChecker.checkCreation(database, rules, false, 
shardingRuleConfig));
     }
     
     @Test
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleExecutorTest.java
index 3546de94994..8add94fdfa1 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleExecutorTest.java
@@ -21,7 +21,7 @@ import lombok.SneakyThrows;
 import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
 import org.apache.shardingsphere.distsql.statement.DistSQLStatement;
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
-import 
org.apache.shardingsphere.infra.algorithm.core.exception.type.InvalidAlgorithmConfigurationException;
+import 
org.apache.shardingsphere.infra.algorithm.core.exception.type.AlgorithmInitializationException;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
 import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
@@ -138,7 +138,7 @@ class CreateShardingTableRuleExecutorTest {
                 + 
"TYPE(NAME='inline',PROPERTIES('algorithm-expression'='t_order_item_${order_id 
% 4}')),"
                 + 
"KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME='snowflake')))";
         CreateShardingTableRuleStatement distSQLStatement = 
(CreateShardingTableRuleStatement) getDistSQLStatement(sql);
-        assertThrows(InvalidAlgorithmConfigurationException.class, () -> 
executor.checkBeforeUpdate(distSQLStatement));
+        assertThrows(AlgorithmInitializationException.class, () -> 
executor.checkBeforeUpdate(distSQLStatement));
     }
     
     @Test
diff --git 
a/infra/algorithm/core/src/main/java/org/apache/shardingsphere/infra/algorithm/core/exception/type/AlgorithmInUsedException.java
 
b/infra/algorithm/core/src/main/java/org/apache/shardingsphere/infra/algorithm/core/exception/type/AlgorithmInUsedException.java
index b605f7a7ac2..3138bf5c787 100644
--- 
a/infra/algorithm/core/src/main/java/org/apache/shardingsphere/infra/algorithm/core/exception/type/AlgorithmInUsedException.java
+++ 
b/infra/algorithm/core/src/main/java/org/apache/shardingsphere/infra/algorithm/core/exception/type/AlgorithmInUsedException.java
@@ -30,6 +30,6 @@ public final class AlgorithmInUsedException extends 
AlgorithmDefinitionException
     private static final long serialVersionUID = -8735125626190637177L;
     
     public AlgorithmInUsedException(final String type, final String 
databaseName, final Collection<String> algorithmNames) {
-        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 94, "%s algorithms '%s' in 
database '%s' are still in used.", type, algorithmNames, databaseName);
+        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 93, "%s algorithms '%s' in 
database '%s' are still in used.", type, algorithmNames, databaseName);
     }
 }
diff --git 
a/infra/algorithm/core/src/main/java/org/apache/shardingsphere/infra/algorithm/core/exception/type/InvalidAlgorithmConfigurationException.java
 
b/infra/algorithm/core/src/main/java/org/apache/shardingsphere/infra/algorithm/core/exception/type/InvalidAlgorithmConfigurationException.java
index ae7b934534b..6fc39f4d729 100644
--- 
a/infra/algorithm/core/src/main/java/org/apache/shardingsphere/infra/algorithm/core/exception/type/InvalidAlgorithmConfigurationException.java
+++ 
b/infra/algorithm/core/src/main/java/org/apache/shardingsphere/infra/algorithm/core/exception/type/InvalidAlgorithmConfigurationException.java
@@ -27,15 +27,11 @@ public final class InvalidAlgorithmConfigurationException 
extends AlgorithmDefin
     
     private static final long serialVersionUID = 1352014079406440573L;
     
-    public InvalidAlgorithmConfigurationException(final String algorithmType, 
final String algorithm, final String message) {
-        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 93, "Invalid %s algorithm 
'%s', %s.", algorithmType, algorithm, message);
-    }
-    
     public InvalidAlgorithmConfigurationException(final String algorithmType, 
final String algorithm) {
-        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 93, "Invalid %s algorithm 
`%s`.", algorithmType, algorithm);
+        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 94, "Invalid %s algorithm 
configuration '%s'.", algorithmType, algorithm);
     }
     
     public InvalidAlgorithmConfigurationException(final String algorithmType) {
-        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 93, "Invalid %s 
algorithm.", algorithmType);
+        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 94, "Invalid %s algorithm 
configuration.", algorithmType);
     }
 }

Reply via email to