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 2021/06/22 11:41:18 UTC

[GitHub] [shardingsphere] strongduanmu opened a new issue #10923: Refactor SELECT_PARTIAL_DISTINCT_AGGREGATION_SQL_FOR_SHARDING_TABLE statement with shardingsphere-integration-test

strongduanmu opened a new issue #10923:
URL: https://github.com/apache/shardingsphere/issues/10923


   Hi community,
   
   This issue is for #10887.
   
   # Background
   
   Currently `FederateStatementTest` and `FederatePrepareStatementTest` use JUNIT to test SQL statements. In order to improve test coverage and code elegance, we need to migrate the test scenarios of FederateStatementTest and FederatePrepareStatementTest to `shardingsphere-integration-test`. 
   
   # Target
   
   The goal of this issue is to migrate the `SELECT_SQL_BY_ID_ACROSS_SINGLE_AND_SHARDING_TABLES` statement to the `shardingsphere-integration-test` module. 
   
   You can search for the `SELECT_SQL_BY_ID_ACROSS_SINGLE_AND_SHARDING_TABLES` keyword, and then you will find the test cases in `FederateStatementTest` and `FederatePrepareStatementTest`.
   
   FederateStatementTest:
   
   ```java
       private static final String SELECT_PARTIAL_DISTINCT_AGGREGATION_SQL_FOR_SHARDING_TABLE =
               "SELECT SUM(DISTINCT user_id), SUM(order_id_sharding) FROM t_order_federate_sharding WHERE order_id_sharding > 1000";
   
       @Test
       public void assertPartialDistinctAggregationForShardingTableWithFederateByExecuteQuery() throws SQLException {
           assertPartialDistinctAggregationForShardingTableWithFederate(true);
       }
       
       @Test
       public void assertPartialDistinctAggregationForShardingTableWithFederateByExecute() throws SQLException {
           assertPartialDistinctAggregationForShardingTableWithFederate(false);
       }
       
       private void assertPartialDistinctAggregationForShardingTableWithFederate(final boolean executeQuery) throws SQLException {
           Statement statement = getShardingSphereDataSource().getConnection().createStatement();
           ResultSet resultSet = getResultSet(statement, SELECT_PARTIAL_DISTINCT_AGGREGATION_SQL_FOR_SHARDING_TABLE, executeQuery);
           assertNotNull(resultSet);
           assertTrue(resultSet.next());
           assertThat(resultSet.getInt(1), is(21));
           assertThat(resultSet.getInt(2), is(4222));
           assertNotNull(resultSet);
       }
   ```
   
   FederatePrepareStatementTest:
   
   ```java
       private static final String SELECT_PARTIAL_DISTINCT_AGGREGATION_SQL_FOR_SHARDING_TABLE =
               "SELECT SUM(DISTINCT user_id), SUM(order_id_sharding) FROM t_order_federate_sharding WHERE order_id_sharding > ?";
   
       @Test
       public void assertPartialDistinctAggregationForShardingTableWithFederateByExecuteQuery() throws SQLException {
           assertPartialDistinctAggregationForShardingTableWithFederate(true);
       }
       
       @Test
       public void assertPartialDistinctAggregationForShardingTableWithFederateByExecute() throws SQLException {
           assertPartialDistinctAggregationForShardingTableWithFederate(false);
       }
       
       private void assertPartialDistinctAggregationForShardingTableWithFederate(final boolean executeQuery) throws SQLException {
           PreparedStatement preparedStatement = getShardingSphereDataSource().getConnection().prepareStatement(SELECT_PARTIAL_DISTINCT_AGGREGATION_SQL_FOR_SHARDING_TABLE);
           preparedStatement.setInt(1, 1000);
           ResultSet resultSet = getResultSet(preparedStatement, executeQuery);
           assertNotNull(resultSet);
           assertTrue(resultSet.next());
           assertThat(resultSet.getInt(1), is(21));
           assertThat(resultSet.getInt(2), is(4222));
           assertNotNull(resultSet);
       }
   ```
   
   # How to
   In order to finish this task, you need to understand the [documentation](https://shardingsphere.apache.org/document/current/en/features/test-engine/integration-test/) of the integration test first, and PR #10913 also provides an example, which you can refer to. BTW, if you have any questions, please leave a comment.


-- 
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:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu closed issue #10923: Refactor SELECT_PARTIAL_DISTINCT_AGGREGATION_SQL_FOR_SHARDING_TABLE statement with shardingsphere-integration-test

Posted by GitBox <gi...@apache.org>.
strongduanmu closed issue #10923:
URL: https://github.com/apache/shardingsphere/issues/10923


   


-- 
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



[GitHub] [shardingsphere] strongduanmu commented on issue #10923: Refactor SELECT_PARTIAL_DISTINCT_AGGREGATION_SQL_FOR_SHARDING_TABLE statement with shardingsphere-integration-test

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #10923:
URL: https://github.com/apache/shardingsphere/issues/10923#issuecomment-904211861


   > @strongduanmu I have finished it
   
   @LeeGuoPing Great job, i will review this pr.


-- 
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



[GitHub] [shardingsphere] LeeGuoPing commented on issue #10923: Refactor SELECT_PARTIAL_DISTINCT_AGGREGATION_SQL_FOR_SHARDING_TABLE statement with shardingsphere-integration-test

Posted by GitBox <gi...@apache.org>.
LeeGuoPing commented on issue #10923:
URL: https://github.com/apache/shardingsphere/issues/10923#issuecomment-903595606


   @strongduanmu  I have finished 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



[GitHub] [shardingsphere] LeeGuoPing commented on issue #10923: Refactor SELECT_PARTIAL_DISTINCT_AGGREGATION_SQL_FOR_SHARDING_TABLE statement with shardingsphere-integration-test

Posted by GitBox <gi...@apache.org>.
LeeGuoPing commented on issue #10923:
URL: https://github.com/apache/shardingsphere/issues/10923#issuecomment-902581514


   Please assign it to me


-- 
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



[GitHub] [shardingsphere] strongduanmu commented on issue #10923: Refactor SELECT_PARTIAL_DISTINCT_AGGREGATION_SQL_FOR_SHARDING_TABLE statement with shardingsphere-integration-test

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #10923:
URL: https://github.com/apache/shardingsphere/issues/10923#issuecomment-902582202


   @LeeGuoPing Welcome.


-- 
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