johnny2002 edited a comment on issue #7471:
URL: https://github.com/apache/shardingsphere/issues/7471#issuecomment-699725247


   This is another way. By this way, we try to compatible with config of old 
version, and the same style of datasource template.
   
   ```yaml
   rules:
   - !SHARDING
     tables:
       template_item_id: #tables that sharding by item_id 
         actualDataNodes: ds_${0..1}.${LOGIC_TABLE}_${0..4}
         databaseStrategy:
             type: INLINE
           shardingColumns: item_id
           props:
             #algorithm-expression: ds_${item_id % 2}
             algorithm-expression: ${item_id % 2} #ignore "ds_", since it's 
already in actualDataNodes
         tableStrategy: 
           type: INLINE
           shardingColumns: item_id
           props:
             algorithm-expression: ${item_id % 5} #ignore "${LOGIC_TABLE}_", 
since it's already in actualDataNodes
       template_order_id:  #tables that sharding by order_id
         actualDataNodes: ds_${0..1}.${LOGIC_TABLE}${0..9}
         #use defaultDatabaseStrategy
         tableStrategy: 
           type: INLINE
           shardingColumns: order_id
           props:
             algorithm-expression: ${order_id % 10} #ignore "${LOGIC_TABLE}_", 
since it's already in actualDataNodes
       t_order:
         template: template_order_id #reference to template_order_id
         tableStrategy:
           shardingColumns: id # can override the value of 
tableStrategy.shardingColumns from template.
       t_order_item:
         template: template_order_id
   
   
   ```


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

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


Reply via email to