joooohnli opened a new issue #1935: Route error when query table sharded by 
string column
URL: https://github.com/apache/incubator-shardingsphere/issues/1935
 
 
   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub 
issues](https://github.com/sharding-sphere/sharding-sphere/issues).
   - Read documentation: [ShardingSphere 
Doc](http://shardingsphere.io/document/current/en/overview/).
   
   Please pay attention on issues you submitted, because we maybe need more 
details. 
   If no response **more than 7 days** and we cannot reproduce it on current 
information, we will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   3.1.0
   ### Which project did you use? Sharding-JDBC or Sharding-Proxy?
   Sharding-JDBC
   ### Expected behavior
   no error
   ### Actual behavior
   ```
   ERROR 3054 (HY000): Unknown exception: java.lang.Integer cannot be cast to 
java.lang.String
   ```
   ### Reason analyze (If you can)
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   1. configure a string column A as sharding column.
   2. select * from x where A='abc';
   3. error
   
   my preciseAlgorithmClass:
   ```
   public class StringHash128By30Char implements 
PreciseShardingAlgorithm<String> {
       private PartitionByString partitionByString = new PartitionByString(128, 
":30");
   
       @Override
       public String doSharding(Collection<String> availableTargetNames, 
PreciseShardingValue<String> shardingValue) {
           for (String availableTargetName : availableTargetNames) {
               Integer calculate = 
partitionByString.calculate(shardingValue.getValue());
               String suffix = String.format("_%03d", calculate);
               if (availableTargetName.endsWith(suffix)) {
                   return availableTargetName;
               }
           }
           throw new UnsupportedOperationException("sharding value:" + 
shardingValue);
       }
   
   }
   ```
   I debug and find shardingValue.value=-1
   
   ### Example codes for reproduce this issue (such as a github link).
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to