Oliver-GMJ opened a new issue, #26922:
URL: https://github.com/apache/shardingsphere/issues/26922

   ### Which version of ShardingSphere did you use?
   5.4.0
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   
   ### Expected behavior
   
   ### Actual behavior
   
   ### Reason analyze (If you can)
   When rules was configured, run SQL wrong.
   
   shardingConfig.yml
   ```
   dataSources:
     master:
       driverClassName: org.postgresql.Driver
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
       jdbcUrl: jdbc:postgresql://localhost:5432/my_table
       password: 123
       username: root
   props:
     sql-show: true
   # Can't execute SQL with custom rules
   rules:
   - !SHARDING
     tables:
       tb_shard:
         actualDataNodes: master.tb_shard_error
         tableStrategy:
           complex:
             shardingAlgorithmName: my_complex_algorithm
             shardingColumns: col_1,col_2
   
     shardingAlgorithms:
       my_complex_algorithm:
         type: CLASS_BASED
         props:
           strategy: COMPLEX
           algorithmClassName: com.xxx.MyComplexShardingAlgorithm
   ```
   MyComplexShardingAlgorithm.java
   ```Java
   package com.xxx;
   
   public class MyComplexShardingAlgorithm implements 
ComplexKeysShardingAlgorithm<String> {
       @Override
       public Collection<String> doSharding(Collection<String> databaseNames, 
ComplexKeysShardingValue<String> shardingValue) {
           return Collections.singletonList("tb_test");
       }
   }
   ```
   Exception:
   This table is not sharding table.
   ```
   Caused by: org.springframework.jdbc.UncategorizedSQLException: 
   ### Error querying database.  Cause: 
org.apache.shardingsphere.dialect.postgresql.exception.PostgreSQLException
   ### The error may exist in com/xxx/dao/mapper/DemoMapper.java (best guess)
   ### The error may involve defaultParameterMap
   ### The error occurred while setting parameters
   ### SQL: SELECT   id,name   FROM tb_demo
   ### Cause: 
org.apache.shardingsphere.dialect.postgresql.exception.PostgreSQLException
   ; uncategorized SQLException; SQL state [99999]; error code [0]; null; 
nested exception is 
org.apache.shardingsphere.dialect.postgresql.exception.PostgreSQLException
   ```
   It works success while I remove rules config.
   ```
   INFO [main] INFO ShardingSphere-SQL - Actual SQL: master ::: SELECT  
   id,name
     FROM tb_demo
   <==    Columns: id, name
   <==        Row: 1, 'xxx'
   <==      Total: 1
   ```
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   
   ### 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 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