justbk2015 opened a new issue #10635:
URL: https://github.com/apache/shardingsphere/issues/10635


   ## Bug Report
   this sql can't right run on ss-proxy.
   ### Which version of ShardingSphere did you use?
   branch of opengauss_adapt 
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   Sharding-Proxy
   ### Expected behavior
   run with no exception.
   ### Actual behavior
   run with exception. see error trace:
   
![image](https://user-images.githubusercontent.com/12265143/120617245-8160c380-c48c-11eb-8491-d18f3ddaf213.png)
   
   ### Reason analyze (If you can)
   logic table rewrite failed! if I rewrite with right sql, it's run with no 
error.
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   1. sharding-config:
       **bmsql_customer:**
         actualDataNodes: ds_${0..0}.bmsql_customer_${0..0}
         databaseStrategy:
           standard:
             shardingAlgorithmName: ds_bmsql_customer_inline
             shardingColumn: c_w_id
         tableStrategy:
           standard:
             shardingAlgorithmName: tb_bmsql_customer_inline
             shardingColumn: c_id
       **bmsql_warehouse:**
         actualDataNodes: ds_${0..0}.bmsql_warehouse_${0..0}
         databaseStrategy:
           standard:
             shardingAlgorithmName: ds_bmsql_warehouse_inline
             shardingColumn: w_id
         tableStrategy:
           standard:
             shardingAlgorithmName: tb_bmsql_warehouse_inline
             shardingColumn: w_id
   ------- all algorithm just mod with 1, like blow:
       tb_bmsql_warehouse_inline:
         props:
           algorithm-expression: bmsql_warehouse_${w_id % 1}
         type: INLINE
   2. table define:
   create table bmsql_warehouse (
     w_id        integer   not null,
     w_ytd       decimal(12,2),
     w_tax       decimal(4,4),
     w_name      varchar(10),
     w_street_1  varchar(20),
     w_street_2  varchar(20),
     w_city      varchar(20),
     w_state     char(2),
     w_zip       char(9)
   );
   create table bmsql_customer (
     c_w_id         integer        not null,
     c_d_id         integer        not null,
     c_id           integer        not null,
     c_discount     decimal(4,4),
     c_credit       char(2),
     c_last         varchar(16),
     c_first        varchar(16),
     c_credit_lim   decimal(12,2),
     c_balance      decimal(12,2),
     c_ytd_payment  decimal(12,2),
     c_payment_cnt  integer,
     c_delivery_cnt integer,
     c_street_1     varchar(20),
     c_street_2     varchar(20),
     c_city         varchar(20),
     c_state        char(2),
     c_zip          char(9),
     c_phone        char(16),
     c_since        timestamp,
     c_middle       char(2),
     c_data         varchar(500)
   );
   3. run sql
   "SELECT c_discount, c_last, c_credit, w_tax " +
                   "    FROM bmsql_customer c " +
                   "    JOIN bmsql_warehouse w ON (w.w_id = c.c_w_id) " +
                   "    WHERE c_w_id = ? AND c_d_id = ? AND c_id = ?" 
   with param 1, 3, 1912
   3. get result
   
![image](https://user-images.githubusercontent.com/12265143/120618064-4612c480-c48d-11eb-87df-056283f8c986.png)
   
   ### Example codes for reproduce this issue (such as a github link).
       @Test
       public void testSqlXx() throws SQLException {
           String sql = "SELECT c_discount, c_last, c_credit, w_tax " +
                   "    FROM bmsql_customer c " +
                   "    JOIN bmsql_warehouse w ON (w.w_id = c.c_w_id) " +
                   "    WHERE c_w_id = ? AND c_d_id = ? AND c_id = ?"
                   ;
           Object[] params = new Object[] {1, 3, 1912};
   
           try (PreparedStatement ps = conn.prepareStatement(sql)) {
               setPsParam(ps, params);
               ps.execute();
           }
       }
   
       private void setPsParam(PreparedStatement ps, Object[] params) {
           IntStream.range(0, params.length).forEach(idx -> {
               try {
                   ps.setObject(idx + 1, params[idx]);
               } catch (SQLException throwables) {
                   throwables.printStackTrace();
               }
           });
       }


-- 
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:
[email protected]


Reply via email to