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

duanzhengqiang 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 e81e3e1fa15 Remove check inline sharding algorithms in table rules 
(#36999)
e81e3e1fa15 is described below

commit e81e3e1fa154be8308d040a8b4e0f505beacf4f5
Author: ZhangCheng <[email protected]>
AuthorDate: Tue Nov 4 11:40:33 2025 +0800

    Remove check inline sharding algorithms in table rules (#36999)
    
    * Remove check inline sharding algorithms in table rules
    
    * Remove check inline sharding algorithms in table rules
    
    * Remove check inline sharding algorithms in table rules
    
    * Remove check inline sharding algorithms in table rules
    
    * Remove check inline sharding algorithms in table rules
    
    * Remove check inline sharding algorithms in table rules
---
 RELEASE-NOTES.md                                   |  1 +
 .../user-manual/error-code/sql-error-code.cn.md    |  4 +--
 .../user-manual/error-code/sql-error-code.en.md    |  4 +--
 ...atchedShardingDataSourceRouteInfoException.java |  9 ++++--
 .../NoShardingDatabaseRouteInfoException.java      |  8 ++++--
 .../type/standard/ShardingStandardRouteEngine.java |  4 +--
 .../sharding/rule/checker/ShardingRuleChecker.java | 33 ----------------------
 .../sharding/rule/ShardingRuleTest.java            | 10 -------
 8 files changed, 19 insertions(+), 54 deletions(-)

diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index ffad56b07d0..77c5ad6f4fc 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -79,6 +79,7 @@
 1. Mode: Fix issue of drop schema can not work on standalone mode - 
[#34470](https://github.com/apache/shardingsphere/pull/34470)
 1. Encrypt: Resolve rewrite issue in nested concat function - 
[#35815](https://github.com/apache/shardingsphere/pull/35815)
 1. Sharding: Fix mod sharding algorithm judgement 
-[#36386](https://github.com/apache/shardingsphere/pull/36386)
+1. Sharding: [Fix check inline sharding algorithms in table 
rules](https://github.com/apache/shardingsphere/pull/36999)
 
 ### Change Logs
 
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 8ca05a28654..4c69c618015 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
@@ -188,8 +188,8 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 | 20051       | HY000     | Routed target '%s' does not exist, available 
targets are '%s'.                                                               
       |
 | 20052       | 44000     | Inline sharding algorithms expression '%s' and 
sharding column '%s' do not match.                                              
     |
 | 20053       | 44000     | Complex inline algorithm need %d sharding columns, 
but only found %d.                                                              
 |
-| 20054       | 44000     | No sharding database route info.                   
                                                                                
 |
-| 20055       | 44000     | Some routed data sources do not belong to 
configured data sources. routed data sources '%s', configured data sources 
'%s'.          |
+| 20054       | 44000     | No sharding database route info, actual data 
source names: `%s`, sharding condition values: `%s`.                            
       |
+| 20055       | 44000     | Some routed data sources do not belong to 
configured data sources. routed data sources '%s', configured data sources 
'%s', sharding condition values '%s'.          |
 | 20056       | 44000     | Please check your sharding conditions '%s' to 
avoid same record in table '%s' routing to multiple data nodes.                 
      |
 | 20057       | 44000     | Can not find routing table factor, data source 
'%s', actual table '%s'.                                                        
     |
 | 20060       | HY000     | Invalid %s strategy '%s', strategy does not match 
data nodes.                                                                     
  |
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 0398d11adde..20f4d2ebe3c 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
@@ -188,8 +188,8 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 | 20051       | HY000     | Routed target '%s' does not exist, available 
targets are '%s'.                                                               
       |
 | 20052       | 44000     | Inline sharding algorithms expression '%s' and 
sharding column '%s' do not match.                                              
     |
 | 20053       | 44000     | Complex inline algorithm need %d sharding columns, 
but only found %d.                                                              
 |
-| 20054       | 44000     | No sharding database route info.                   
                                                                                
 |
-| 20055       | 44000     | Some routed data sources do not belong to 
configured data sources. routed data sources '%s', configured data sources 
'%s'.          |
+| 20054       | 44000     | No sharding database route info, actual data 
source names: `%s`, sharding condition values: `%s`.                            
       |
+| 20055       | 44000     | Some routed data sources do not belong to 
configured data sources. routed data sources '%s', configured data sources 
'%s', sharding condition values '%s'.          |
 | 20056       | 44000     | Please check your sharding conditions '%s' to 
avoid same record in table '%s' routing to multiple data nodes.                 
      |
 | 20057       | 44000     | Can not find routing table factor, data source 
'%s', actual table '%s'.                                                        
     |
 | 20060       | HY000     | Invalid %s strategy '%s', strategy does not match 
data nodes.                                                                     
  |
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/MismatchedShardingDataSourceRouteInfoException.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/MismatchedShardingDataSourceRouteInfoException.java
index 1c3165bdb19..e7e02652bf1 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/MismatchedShardingDataSourceRouteInfoException.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/MismatchedShardingDataSourceRouteInfoException.java
@@ -19,6 +19,7 @@ package 
org.apache.shardingsphere.sharding.exception.algorithm;
 
 import 
org.apache.shardingsphere.infra.exception.external.sql.sqlstate.XOpenSQLState;
 import org.apache.shardingsphere.sharding.exception.ShardingSQLException;
+import 
org.apache.shardingsphere.sharding.route.engine.condition.value.ShardingConditionValue;
 
 import java.util.Collection;
 
@@ -29,8 +30,10 @@ public final class 
MismatchedShardingDataSourceRouteInfoException extends Shardi
     
     private static final long serialVersionUID = -345707079477626285L;
     
-    public MismatchedShardingDataSourceRouteInfoException(final 
Collection<String> routeDataSourceNames, final Collection<String> 
actualDataSourceNames) {
-        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 55, "Some routed data 
sources do not belong to configured data sources. routed data sources '%s', 
configured data sources '%s'.",
-                routeDataSourceNames, actualDataSourceNames);
+    public MismatchedShardingDataSourceRouteInfoException(final 
Collection<String> routeDataSourceNames, final Collection<String> 
actualDataSourceNames,
+                                                          final 
Collection<ShardingConditionValue> shardingConditionValues) {
+        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 55,
+                "Some routed data sources do not belong to configured data 
sources. routed data sources '%s', configured data sources '%s', sharding 
condition values '%s'.",
+                routeDataSourceNames, actualDataSourceNames, 
shardingConditionValues);
     }
 }
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/NoShardingDatabaseRouteInfoException.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/NoShardingDatabaseRouteInfoException.java
index 59d6009b081..e3210085969 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/NoShardingDatabaseRouteInfoException.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/NoShardingDatabaseRouteInfoException.java
@@ -19,6 +19,9 @@ package 
org.apache.shardingsphere.sharding.exception.algorithm;
 
 import 
org.apache.shardingsphere.infra.exception.external.sql.sqlstate.XOpenSQLState;
 import org.apache.shardingsphere.sharding.exception.ShardingSQLException;
+import 
org.apache.shardingsphere.sharding.route.engine.condition.value.ShardingConditionValue;
+
+import java.util.Collection;
 
 /**
  * No database route info exception.
@@ -27,7 +30,8 @@ public final class NoShardingDatabaseRouteInfoException 
extends ShardingSQLExcep
     
     private static final long serialVersionUID = -3091336980350038243L;
     
-    public NoShardingDatabaseRouteInfoException() {
-        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 54, "No sharding database 
route info.");
+    public NoShardingDatabaseRouteInfoException(final Collection<String> 
actualDataSourceNames, final Collection<ShardingConditionValue> 
shardingConditionValues) {
+        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 54, "No sharding database 
route info, actual data source names: `%s`, sharding condition values: `%s`.", 
actualDataSourceNames,
+                shardingConditionValues);
     }
 }
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/standard/ShardingStandardRouteEngine.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/standard/ShardingStandardRouteEngine.java
index b264ba22c9d..bb2d91db938 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/standard/ShardingStandardRouteEngine.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/standard/ShardingStandardRouteEngine.java
@@ -260,9 +260,9 @@ public final class ShardingStandardRouteEngine implements 
ShardingRouteEngine {
             return shardingTable.getActualDataSourceNames();
         }
         Collection<String> result = 
databaseShardingStrategy.doSharding(shardingTable.getActualDataSourceNames(), 
databaseShardingValues, shardingTable.getDataSourceDataNode(), props);
-        ShardingSpherePreconditions.checkNotEmpty(result, 
NoShardingDatabaseRouteInfoException::new);
+        ShardingSpherePreconditions.checkNotEmpty(result, () -> new 
NoShardingDatabaseRouteInfoException(shardingTable.getActualDataSourceNames(), 
databaseShardingValues));
         
ShardingSpherePreconditions.checkState(shardingTable.getActualDataSourceNames().containsAll(result),
-                () -> new 
MismatchedShardingDataSourceRouteInfoException(result, 
shardingTable.getActualDataSourceNames()));
+                () -> new 
MismatchedShardingDataSourceRouteInfoException(result, 
shardingTable.getActualDataSourceNames(), databaseShardingValues));
         return result;
     }
     
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/checker/ShardingRuleChecker.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/checker/ShardingRuleChecker.java
index 5cc0a601512..881d942f04f 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/checker/ShardingRuleChecker.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/checker/ShardingRuleChecker.java
@@ -19,17 +19,13 @@ package org.apache.shardingsphere.sharding.rule.checker;
 
 import com.google.common.base.Splitter;
 import lombok.RequiredArgsConstructor;
-import 
org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
 import org.apache.shardingsphere.infra.datanode.DataNode;
-import org.apache.shardingsphere.infra.datanode.DataNodeInfo;
 import org.apache.shardingsphere.infra.exception.ShardingSpherePreconditions;
-import 
org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineShardingAlgorithm;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableReferenceRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.ComplexShardingStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
-import 
org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
 import 
org.apache.shardingsphere.sharding.exception.metadata.DuplicateShardingActualDataNodeException;
 import 
org.apache.shardingsphere.sharding.exception.metadata.InvalidBindingTablesException;
 import 
org.apache.shardingsphere.sharding.exception.metadata.ShardingTableRuleNotFoundException;
@@ -59,7 +55,6 @@ public class ShardingRuleChecker {
     public void check(final ShardingRuleConfiguration ruleConfig) {
         checkUniqueActualDataNodesInTableRules();
         checkBindingTableConfiguration(ruleConfig);
-        checkInlineShardingAlgorithmsInTableRules();
     }
     
     private void checkUniqueActualDataNodesInTableRules() {
@@ -151,34 +146,6 @@ public class ShardingRuleChecker {
         return null == shardingColumn ? "" : shardingColumn;
     }
     
-    private void checkInlineShardingAlgorithmsInTableRules() {
-        shardingRule.getShardingTables().forEach((key, value) -> {
-            validateInlineShardingAlgorithm(value, 
shardingRule.getTableShardingStrategyConfiguration(value), 
value.getTableDataNode());
-            validateInlineShardingAlgorithm(value, 
shardingRule.getDatabaseShardingStrategyConfiguration(value), 
value.getDataSourceDataNode());
-        });
-    }
-    
-    private void validateInlineShardingAlgorithm(final ShardingTable 
shardingTable, final ShardingStrategyConfiguration shardingStrategy, final 
DataNodeInfo dataNodeInfo) {
-        if (null == shardingStrategy) {
-            return;
-        }
-        ShardingAlgorithm shardingAlgorithm = 
shardingRule.getShardingAlgorithms().get(shardingStrategy.getShardingAlgorithmName());
-        if (shardingAlgorithm instanceof InlineShardingAlgorithm) {
-            String shardingColumn = null == 
((StandardShardingStrategyConfiguration) shardingStrategy).getShardingColumn() 
? shardingRule.getDefaultShardingColumn()
-                    : ((StandardShardingStrategyConfiguration) 
shardingStrategy).getShardingColumn();
-            String result = null;
-            try {
-                result = ((InlineShardingAlgorithm) 
shardingAlgorithm).doSharding(Collections.emptySet(), new 
PreciseShardingValue<>(shardingTable.getLogicTable(), shardingColumn, 
dataNodeInfo, 1));
-                // CHECKSTYLE:OFF
-            } catch (final Exception ignored) {
-                // CHECKSTYLE:ON
-            }
-            ShardingSpherePreconditions.checkState(null == result || 
result.startsWith(dataNodeInfo.getPrefix()),
-                    () -> new 
AlgorithmInitializationException(shardingAlgorithm, "`%s` sharding algorithm 
configuration of `%s` does not match the actual data nodes",
-                            shardingStrategy.getShardingAlgorithmName(), 
shardingTable.getLogicTable()));
-        }
-    }
-    
     /**
      * Check to be added data nodes.
      *
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
index 016195b5ae5..6ab39ae9e63 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
@@ -177,16 +177,6 @@ class ShardingRuleTest {
         assertThrows(DuplicateShardingActualDataNodeException.class, () -> new 
ShardingRule(ruleConfig, Collections.emptyMap(), 
mock(ComputeNodeInstanceContext.class), Collections.emptyList()));
     }
     
-    @Test
-    void assertValidateWrongInlineShardingAlgorithmsInTableRules() {
-        ShardingRuleConfiguration ruleConfig = new ShardingRuleConfiguration();
-        ShardingTableRuleConfiguration tableRuleConfig = new 
ShardingTableRuleConfiguration("t_order", "ds_${0..1}.t_order_tmp_${0..1}");
-        tableRuleConfig.setTableShardingStrategy(new 
StandardShardingStrategyConfiguration("order_id", "order_id_inline"));
-        ruleConfig.getTables().add(tableRuleConfig);
-        ruleConfig.getShardingAlgorithms().put("order_id_inline", new 
AlgorithmConfiguration("INLINE", PropertiesBuilder.build(new 
Property("algorithm-expression", "t_order_${order_id % 2}"))));
-        assertThrows(AlgorithmInitializationException.class, () -> new 
ShardingRule(ruleConfig, Collections.emptyMap(), 
mock(ComputeNodeInstanceContext.class), Collections.emptyList()));
-    }
-    
     @Test
     void assertValidateInlineShardingAlgorithmsInTableRules() {
         ShardingRuleConfiguration ruleConfig = new ShardingRuleConfiguration();

Reply via email to