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

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   org.apache.shardingsphere:shardingsphere-jdbc:5.5.2
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   shardingsphere-jdbc
   ### Expected behavior
   normal work
   ### Actual behavior
   ```Cause: 
org.apache.shardingsphere.infra.exception.kernel.metadata.TableNotFoundException:
 Table or view 'im_user' does not exist.```
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   sharding-jdbc.yaml:
   ```yaml
   dataSources:
     user0:
       url: 
jdbc:mysql://localhost:3306/user0?useUnicode=true&characterEncoding=utf-8&useSSL=false&verifyServerCertificate=false&serverTimezone=Asia/Shanghai
       username: root
       password: root
       driverClassName: com.mysql.cj.jdbc.Driver
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
     user1:
       url: 
jdbc:mysql://localhost:3306/user1?useUnicode=true&characterEncoding=utf-8&useSSL=false&verifyServerCertificate=false&serverTimezone=Asia/Shanghai
       username: root
       password: root
       driverClassName: com.mysql.cj.jdbc.Driver
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
     im0:
       url: 
jdbc:mysql://localhost:3306/im0?useUnicode=true&characterEncoding=utf-8&useSSL=false&verifyServerCertificate=false&serverTimezone=Asia/Shanghai
       username: root
       password: root
       driverClassName: com.mysql.cj.jdbc.Driver
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
     im1:
       url: 
jdbc:mysql://localhost:3306/im1?useUnicode=true&characterEncoding=utf-8&useSSL=false&verifyServerCertificate=false&serverTimezone=Asia/Shanghai
       username: root
       password: root
       driverClassName: com.mysql.cj.jdbc.Driver
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
   
   rules:
     - !SHARDING
       tables:
         t_user:
           actualDataNodes: user$->{0..1}.user
           databaseStrategy:
             standard:
               shardingColumn: user_id
               shardingAlgorithmName: t_user_inline
         im_user:
           actualDataNodes: im$->{0..1}.user
           databaseStrategy:
             standard:
               shardingColumn: customer_id
               shardingAlgorithmName: im_user_inline
   
       shardingAlgorithms:
         t_user_inline:
           type: INLINE
           props:
             algorithm-expression: user$->{Long.parseLong(user_id[-4..-1]) % 2}
             allow-range-query-with-inline-sharding: true
         im_user_inline:
           type: INLINE
           props:
             algorithm-expression: im$->{Long.parseLong(customer_id[-4..-1]) % 
2}
             allow-range-query-with-inline-sharding: true
   
   props:
     sql-show: true
   ```
   When I use the following SQL query:
   `select * from im_user where customer_id = 1844931181183901728`
   An exception occurred:
   ```
   Caused by: 
org.apache.shardingsphere.infra.exception.kernel.metadata.TableNotFoundException:
 Table or view 'im_user' does not exist.
        at 
org.apache.shardingsphere.infra.binder.engine.segment.dml.from.type.SimpleTableSegmentBinder.lambda$checkTableExists$12(SimpleTableSegmentBinder.java:178)
 ~[shardingsphere-infra-binder-5.5.2.jar:5.5.2]
        at 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions.checkState(ShardingSpherePreconditions.java:44)
 ~[shardingsphere-infra-exception-core-5.5.2.jar:5.5.2]
        at 
org.apache.shardingsphere.infra.binder.engine.segment.dml.from.type.SimpleTableSegmentBinder.checkTableExists(SimpleTableSegmentBinder.java:178)
 ~[shardingsphere-infra-binder-5.5.2.jar:5.5.2]
        at 
org.apache.shardingsphere.infra.binder.engine.segment.dml.from.type.SimpleTableSegmentBinder.bind(SimpleTableSegmentBinder.java:90)
 ~[shardingsphere-infra-binder-5.5.2.jar:5.5.2]
        at 
org.apache.shardingsphere.infra.binder.engine.segment.dml.from.TableSegmentBinder.bind(TableSegmentBinder.java:57)
 ~[shardingsphere-infra-binder-5.5.2.jar:5.5.2]
        at 
org.apache.shardingsphere.infra.binder.engine.statement.dml.SelectStatementBinder.lambda$bind$1(SelectStatementBinder.java:64)
 ~[shardingsphere-infra-binder-5.5.2.jar:5.5.2]
        at java.base/java.util.Optional.map(Optional.java:260) ~[na:na]
        at 
org.apache.shardingsphere.infra.binder.engine.statement.dml.SelectStatementBinder.bind(SelectStatementBinder.java:64)
 ~[shardingsphere-infra-binder-5.5.2.jar:5.5.2]
        at 
org.apache.shardingsphere.infra.binder.engine.type.DMLStatementBindEngine.bind(DMLStatementBindEngine.java:61)
 ~[shardingsphere-infra-binder-5.5.2.jar:5.5.2]
        at 
org.apache.shardingsphere.infra.binder.engine.SQLBindEngine.bindSQLStatement(SQLBindEngine.java:68)
 ~[shardingsphere-infra-binder-5.5.2.jar:5.5.2]
        at 
org.apache.shardingsphere.infra.binder.engine.SQLBindEngine.bind(SQLBindEngine.java:58)
 ~[shardingsphere-infra-binder-5.5.2.jar:5.5.2]
        at 
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.<init>(ShardingSpherePreparedStatement.java:143)
 ~[shardingsphere-jdbc-5.5.2.jar:5.5.2]
        at 
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.<init>(ShardingSpherePreparedStatement.java:115)
 ~[shardingsphere-jdbc-5.5.2.jar:5.5.2]
        at 
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection.prepareStatement(ShardingSphereConnection.java:108)
 ~[shardingsphere-jdbc-5.5.2.jar:5.5.2]
        at 
com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:328)
 ~[HikariCP-6.3.2.jar:na]
        at 
com.zaxxer.hikari.pool.HikariProxyConnection.prepareStatement(HikariProxyConnection.java)
 ~[HikariCP-6.3.2.jar:na]
        at 
org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:88)
 ~[mybatis-3.5.19.jar:3.5.19]
        at 
org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:90)
 ~[mybatis-3.5.19.jar:3.5.19]
        ... 83 common frames omitted
   ```
   ### Reason analyze (If you can)
   When obtaining a ShardingTable based on the actual table name, if the first 
match is matched, it will be returned directly without additional judgment
   
   
![Image](https://github.com/user-attachments/assets/b335fb12-ba3f-48c5-bd41-4f37fc3a8043)
   
   ### 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