terrymanu commented on issue #29316:
URL: 
https://github.com/apache/shardingsphere/issues/29316#issuecomment-3552465074

   ### Issue Understanding
   
     - In ShardingSphere-JDBC 5.4.1, configuring binding tables fails with 
ShardingRule.isValidActualTableName() when actual table names include business 
digits such as AllPatientsV1.
   
     ### Root Cause
   
     - ShardingTable.createTableDataNode() assumes actual tables follow “common 
prefix + numeric suffix”. It removes trailing digits via 
DATA_NODE_SUFFIX_PATTERN (\d+$):
   
       private DataNodeInfo createTableDataNode(final Collection<DataNode> 
actualDataNodes) {
           String tableName = actualDataNodes.iterator().next().getTableName();
           String prefix = tableName.startsWith(logicTable)
                   ? logicTable + 
ShardingTableConstants.DATA_NODE_SUFFIX_PATTERN.matcher(tableName.substring(logicTable.length())).replaceAll("")
                   : 
ShardingTableConstants.DATA_NODE_SUFFIX_PATTERN.matcher(tableName).replaceAll("");
           int suffixMinLength = actualDataNodes.stream()
                   .map(each -> each.getTableName().length() - prefix.length())
                   .min(Comparator.comparing(Integer::intValue)).orElse(1);
           return new DataNodeInfo(prefix, suffixMinLength, 
ShardingTableConstants.DEFAULT_PADDING_CHAR);
       }
     - As a result, any digits—even those that are part of the real name—are 
stripped during binding-table validation.
   
     ### Issue Analysis
   
     - This behavior reflects the community convention: actual table names must 
share an identical prefix and use pure numeric suffixes so that different logic 
tables align their sharding topology. The “Binding Table Configuration” guide 
(https://shardingsphere.apache.org/
       
document/current/en/user-manual/shardingsphere-jdbc/yaml-config/sharding/binding-tables/)
 describes binding rules but does not explicitly emphasize the numeric-suffix 
constraint.
     - Therefore the current implementation is behaving as designed; supporting 
non-numeric suffixes would require additional features (e.g., customizable 
suffix patterns).
   
     ### Conclusion & Next Steps
   
     - No code change is planned; users should follow the numeric-suffix naming 
convention when defining binding tables (e.g., t_order_0, t_order_1).
     - Documentation needs a clarification: update 
docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/sharding/binding-tables*.md
 to state that actual table names must share a common prefix and end with 
numeric indexes, and provide inline/actualDataNodes
       examples reflecting this rule.
     - We warmly invite community contributors to submit a PR that (1) adds the 
documentation note above, and (2) optionally includes guidance on how to handle 
table names that contain business digits. Please feel free to volunteer on this 
issue—your docs/tests contributions
       are highly appreciated!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to