You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/01/28 10:24:14 UTC

[GitHub] [shardingsphere] SunJiFengPlus opened a new issue #9209: How to deal with table not exist gracefully

SunJiFengPlus opened a new issue #9209:
URL: https://github.com/apache/shardingsphere/issues/9209


   ## Question
   
   After I split the table, I will encounter the table not exist exception when querying. I don't want to catch and handle this exception in the business. Is there any good way to deal with this situation? 
   
   For example I have these tables: ```order2020-02```, ```order2020-03```
   
   and i want to execute this sql
   ``` sql
   SELECT * FROM order WHERE month IN("2020-01", "2020-02", "2020-03");
   ```
   I will get an exception


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #9209: How to deal with table not exist gracefully

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #9209:
URL: https://github.com/apache/shardingsphere/issues/9209#issuecomment-770530326


   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.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] SunJiFengPlus closed issue #9209: How to deal with table not exist gracefully

Posted by GitBox <gi...@apache.org>.
SunJiFengPlus closed issue #9209:
URL: https://github.com/apache/shardingsphere/issues/9209


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #9209: How to deal with table not exist gracefully

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #9209:
URL: https://github.com/apache/shardingsphere/issues/9209#issuecomment-771523753


   Hi,
   
   I can catch you. You get an exception because `ShardingAlgorithm` tells SS to route this SQL to a non-existing table (`order2020-01`) by   ShardingValue (`2020-01`). So suppose you do not want to get this exception, please implement `ShardingAlgorithm` by yourself to avoid returning table `order2020-01`;


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] SunJiFengPlus commented on issue #9209: How to deal with table not exist gracefully

Posted by GitBox <gi...@apache.org>.
SunJiFengPlus commented on issue #9209:
URL: https://github.com/apache/shardingsphere/issues/9209#issuecomment-773918824


   thx 👍 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] SunJiFengPlus commented on issue #9209: How to deal with table not exist gracefully

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #9209: How to deal with table not exist gracefully

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #9209:
URL: https://github.com/apache/shardingsphere/issues/9209#issuecomment-771523753


   Hi,
   
   I can catch you. You get an exception because `ShardingAlgorithm` tells SS to route this SQL to a non-existing table (`order2020-01`) by   ShardingValue (`2020-01`). So suppose you do not want to get this exception, please implement `ShardingAlgorithm` by yourself to avoid returning table `order2020-01`;


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] SunJiFengPlus closed issue #9209: How to deal with table not exist gracefully

Posted by GitBox <gi...@apache.org>.
SunJiFengPlus closed issue #9209:
URL: https://github.com/apache/shardingsphere/issues/9209


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] SunJiFengPlus commented on issue #9209: How to deal with table not exist gracefully

Posted by GitBox <gi...@apache.org>.
SunJiFengPlus commented on issue #9209:
URL: https://github.com/apache/shardingsphere/issues/9209#issuecomment-773918824


   thx 👍 


----------------------------------------------------------------
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:
users@infra.apache.org