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

   • Issue Understanding
     On ShardingSphere-JDBC 5.2.1, using complex sharding on province, 
sharding_month with actual tables like model_check_xxx_${province}_${month}. 
Works without binding-tables, but adding the 8 tables into a binding group 
triggers Invalid binding
     table configuration in ShardingRuleConfiguration.
   
     Root Cause
     Binding-table validation requires that, after removing a common prefix, 
all tables in the group share exactly the same suffix set and that the trailing 
suffix is purely numeric. Your table names carry two dynamic segments (province 
letters +
     month numbers). ShardingRuleChecker derives the prefix assuming “logic 
table + numeric suffix”; it can’t accommodate the extra province segment, so 
suffix sets differ and InvalidBindingTablesException is raised. This is a usage 
limitation, not
     a runtime bug.
   
     Analysis
   
     - Validation path: checkBindingTableConfiguration compares data source 
sets, actual table names after prefix stripping, and sharding algorithm 
expressions; any mismatch fails.
     - Prefix derivation (ShardingTable#createTableDataNode) assumes actual 
names are “logic table + numeric suffix”. With an extra letter segment, the 
stripped suffix differs across tables.
     - Therefore any naming that is not “common prefix + numeric suffix only” 
will make the binding-table check fail.
     - Official docs: Binding tables configuration and FAQ about numeric-only 
suffix constraint:
         - Binding tables: 
https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-jdbc/yaml-config/sharding/#binding-tables
         - FAQ on binding-table validation: 
https://shardingsphere.apache.org/document/current/en/faq/#binding-table-validation
   
     Conclusion
     This is a configuration limitation, not a product defect. Recommended 
actions:
   
     1. Change the naming so tables in the binding group fit “logic table 
prefix + numeric suffix” (e.g., move province to data source/schema or encode 
province into a numeric suffix) to keep suffix sets identical.
     2. If renaming is impossible, remove binding-tables and keep SQL carrying 
all sharding keys (province, sharding_month) to ensure correct routing.


-- 
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