vikiuvb opened a new issue, #22433:
URL: https://github.com/apache/shardingsphere/issues/22433

   ## Feature Request
   
   ### Is your feature request related to a problem?
   
   When we add a new data source, the user has to update all the sharding rules 
to include the newly created data source.
   
   **Example:**
   
   ```
   CREATE SHARDING TABLE RULE t_orders (
     DATANODES("ds_${0..1}.t_orders"),
     DATABASE_STRATEGY(TYPE="standard", SHARDING_COLUMN=user_id, 
SHARDING_ALGORITHM(TYPE(NAME="inline", 
     PROPERTIES("algorithm-expression"="ds_${user_id%2}")))),
     KEY_GENERATE_STRATEGY(COLUMN=record_id, 
KEY_GENERATOR=snowflake_key_generator)
   );
   
   CREATE SHARDING TABLE RULE t_invoices (
     DATANODES("ds_${0..1}.t_invoices"),
     DATABASE_STRATEGY(TYPE="standard", SHARDING_COLUMN=user_id, 
SHARDING_ALGORITHM(TYPE(NAME="inline", 
     PROPERTIES("algorithm-expression"="ds_${user_id%2}")))),
     KEY_GENERATE_STRATEGY(COLUMN=record_id, 
KEY_GENERATOR=snowflake_key_generator)
   );
   ```
   
   When we add a new data source, `ds_2`, we need to update the same in both 
the `t_orders` and `t_invoices` sharding rules. It may look fine for a few 
tables, but it feels mundane for databases with hundreds of sharding rules.
   
   ### Describe the feature you would like.
   
   The problem is mainly because of the tight coupling between the sharding 
rule and data sources. It's ideal to have some sort of indirection between the 
sharding rule and data sources. 
   
   **Proposal:**
   
   Introduce a layer in the middle that can abstract the data sources.
   
   
![image](https://user-images.githubusercontent.com/13797616/204075844-b6136c08-31f1-43b2-8dea-d3dee680606c.png)
   
   
   ```
   CREATE DATASOURCE GROUP t_orders_group (
      DATANODES("ds_${0..1}")
   );
   ```
   ```
   CREATE SHARDING TABLE RULE t_orders (
     DATASOURCE_GROUP("t_orders_group.t_orders"),
     DATABASE_STRATEGY(TYPE="standard", SHARDING_COLUMN=user_id, 
SHARDING_ALGORITHM(TYPE(NAME="inline", 
     PROPERTIES("algorithm-expression"="ds_${user_id%2}")))),
     KEY_GENERATE_STRATEGY(COLUMN=record_id, 
KEY_GENERATOR=snowflake_key_generator)
   );
   ```
    


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