You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/12/06 15:04:01 UTC

[GitHub] [shardingsphere] zhaojinchao95 commented on issue #22553: In the federation scenario, the result of select view is incomplete;

zhaojinchao95 commented on issue #22553:
URL: https://github.com/apache/shardingsphere/issues/22553#issuecomment-1339518961

   ```
   public class JDBCDriver {
       static final String DB_URL = "jdbc:mysql://127.0.0.1:3307/sharding_db";
       static final String USER = "root";
       static final String PASS = "root";
       
       public static void main(String[] args) throws Exception {
           Statement statement = getConnection().createStatement();
           List<String> sqlList = Arrays.asList("drop table if exists t_order;",
                   "create table t_order (order_id int primary key, user_id int not null, status varchar(50) not null, merchant_id int not null, remark varchar(50), creation_date date);");
           String records = "insert into t_order values(1000, 10, 'init', 1, 'test', '2017-07-08')," +
                   "(1001, 10, 'init', 2, 'test', '2017-07-08')," +
                   "(2000, 20, 'init', 3, 'test', '2017-08-08')," +
                   "(2001, 20, 'init', 4, 'test', '2017-08-08')," +
                   "(1100, 11,  'init', 5, 'test', '2017-08-08')," +
                   "(1101, 11, 'init', 6, 'test', '2017-08-08')," +
                   "(2100, 21, 'finish', 7, 'test', '2017-08-08')," +
                   "(2101, 21, 'finish', 8, 'test', '2017-08-08')," +
                   "(1200, 12, 'finish', 9, 'finish', '2017-08-08')," +
                   "(1201, 12, 'finish', 10, 'test22', '2017-08-18')," +
                   "(2200, 22, 'finish', 11, 'test', '2017-08-18')," +
                   "(2201, 22, 'finish', 12, 'test', '2017-08-18')," +
                   "(1300, 13, 'finish', 13, '', '2017-08-18')," +
                   "(1301, 13, 'finish', 14, 'test', '2017-08-18')," +
                   "(2300, 23, 'finish ', 15, 'test', '2017-08-18')," +
                   "(2301, 23, 'finish', 16, 'test', '2017-08-18')," +
                   "(1400, 14, 'init', 17, '', '2017-08-18')," +
                   "(1401, 14, 'init', 18, 'test', '2017-08-18')," +
                   "(2400, 24, 'init', 19, 'test', '2017-08-18')," +
                   "(2401, 24, 'init', 20, 'test', '2017-08-18')," +
                   "(1500, 15, 'init', 1, '', '2017-08-28')," +
                   "(1501, 15, 'init', 2, 'test', '2017-08-28')," +
                   "(2500, 25, 'init', 3, 'test', '2017-08-28')," +
                   "(2501, 25, 'init', 4, 'test', '2017-08-28')," +
                   "(1600, 16, 'init', 5, 'test', '2017-08-28')," +
                   "(1601, 16, 'init', 6, '', '2017-08-28')," +
                   "(2600, 26, 'init', 7, 'test', '2017-08-28')," +
                   "(1700, 17, 'init', 9, 'test', '2017-08-28')," +
                   "(1701, 17, 'finish', 10, 'test', '2017-08-18')," +
                   "(2700, 27, 'finish', 11, 'test', '2017-08-18')," +
                   "(2701, 27, 'finish', 12, 'test', '2017-08-18')," +
                   "(1800, 18, 'finish', 13, 'test', '2017-08-18')," +
                   "(2800, 28, 'finish', 15, 'test', '2017-08-18')," +
                   "(2801, 28, 'finish', 16, 'test', '2017-08-18')," +
                   "(1900, 19, 'init', 17, 'test', '2017-08-18')," +
                   "(1901, 19, 'init', 18, 'test', '2017-08-18')," +
                   "(2900, 29, 'init', 19, 'test', '2017-08-18')," +
                   "(2901, 29, 'init', 20, 'test', '2017-08-18')," +
                   "(1902, 19, 'init', 17, 'test11', '2017-08-18')," +
                   "(1903, 19, 'init', 18, 'test12', '2017-08-18')," +
                   "(2902, 29, 'init', 19, 'test', '2017-08-18')," +
                   "(2903, 29, 'init', 20, 'test', '2017-08-18');";
           for (String each : sqlList) {
               statement.execute(each);
           }
           statement.execute(records);
           statement.execute("create view select_view as select distinct(user_id) from t_order order by user_id;");
           ResultSet rs = statement.executeQuery("select * from select_view;");
           while(rs.next()){
               System.out.println("userId is : " + rs.getInt("user_id"));
           }
       }
       
       private static Connection getConnection() throws Exception {
           Class.forName("com.mysql.jdbc.Driver");
           System.out.println("Connecting to database...");
           return DriverManager.getConnection(DB_URL, USER, PASS);
       }
   }
   ```
   
   <img width="382" alt="image" src="https://user-images.githubusercontent.com/33742097/205947506-7eefe38c-e8f4-4a7e-b58a-9adb2b0bc57b.png">
   
   
   @peilinqian Hi, I can't reproduce it when i use `JDBC` to test it.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org