SunJiFengPlus commented on issue #9209:
URL: https://github.com/apache/shardingsphere/issues/9209#issuecomment-770563906


   > Hi @SunJiFengPlus ,
   > 
   > Which version is using?
   > 
   > Suppose you don't want to create a table named `order2020-02`. In that 
case, another way is to implement the `shardingAlgorithm` interface to ignore 
some certain `shardingValues` in purpose.
   
    Thank you for your reply, i uss sharding-jdbc-core:4.0.0-RC1.
    
   I don't want to ignore some certain shardingvalues, but I'm not sure whether 
the current shardingvalues routing table exists. If the table doesn't exist, I 
don't want to throw an exception, I hope it can customize an empty collection 
to return.
   
   For example I have these tables: ```order2020-02```, ```order2020-03```
   
   i didn't know the table(order2020-01) didn't exist , and i execute
   ``` java
   List<Order> orderList = SqlClient.eval("SELECT * FROM order WHERE month 
IN('2020-01', '2020-02', '2020-03')");
   ```
   I will get an table not exist exception, if I want to convert this exception 
to a custom return, i need to do
   ``` java
   List<Order> orderList = new ArrayList<>();
   try {
       List<Order> month1 = SqlClient.eval("SELECT * FROM order WHERE month = 
'2020-01'");
       orderList.addAll(month1);
   } catch (Exception e) {
       // ignore this exception, add nothing to orderList
   }
   
   try {
       List<Order> month2 = SqlClient.eval("SELECT * FROM order WHERE month = 
'2020-02'");
       orderList.addAll(month2);
   } catch (Exception e) {
       // ignore this exception, add nothing to orderList
   }
   
   try {
       List<Order> month3 = SqlClient.eval("SELECT * FROM order WHERE month = 
'2020-03'");
       orderList.addAll(month3);
   } catch (Exception e) {
       // ignore this exception, add nothing to orderList
   }
   ```
    It seems too much trouble,  is there a simple way to deal with it ?


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