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

   ## 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/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere 
Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more 
details. 
   If no response anymore 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?
   5.5.0
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   ### Expected behavior
   When the following sql is executed, it will be executed in the first data 
source of the configuration:
   `
   with orders as (select * from t_order) select * from orders
   `
   and my sharding.yaml like this:
   `
   dataSources:
     ds0:
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.cj.jdbc.Driver
       jdbcUrl: 
jdbc:mysql://127.0.0.1:3306/ds_0?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&useTimezone=true
       username: root
       password: root
     ds1:
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.cj.jdbc.Driver
       jdbcUrl: 
jdbc:mysql://127.0.0.1:3306/ds_1?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&useTimezone=true
       username: root
       password: root
     - !SINGLE
       tables:
         - ds0.*
         - ds1.*
   `
   t_order is single table and  exists only in ds_1 .Normally, it should be 
executed in ds_1
   
   ### Actual behavior
    it is the sql executed in ds_0. so there is "table not exists" exception
   
   ### Reason analyze (If you can)
   This may be because when getting tableName, the sql in with is not 
extracted. As a result, the table name obtained by the above sql is only 
orders, there is no t_order, and the code location is in 
TableExtractor#extractTablesFromSelect.
   In the end, the route location can not be obtained in SQLRouteEngine, but 
the result of sql rewriting is GenericSQLRewriteResult, and finally the sql is 
executed in ds_0.
   
   ### 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