linghengqian commented on code in PR #37421:
URL: https://github.com/apache/shardingsphere/pull/37421#discussion_r2629934579


##########
test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/TestShardingService.java:
##########
@@ -68,63 +68,36 @@ public void processSuccess() throws SQLException {
     }
     
     /**
-     * Process success in ClickHouse. ClickHouse JDBC Driver does not support 
the use of transactions.
+     * Process success in ClickHouse.
+     * ClickHouse JDBC Driver does not support the use of transactions.
+     * Databases like ClickHouse do not support returning auto generated keys 
after executing SQL,
+     * see <a 
href="https://github.com/ClickHouse/ClickHouse/issues/56228";>ClickHouse/ClickHouse#56228</a>
 .
+     * TODO The current ShardingSphere parsing of ClickHouse's `INNER JOIN` 
syntax has shortcomings,
+     *  and it return incorrect query results for SQL statements such as 
`SELECT i.* FROM t_order o, t_order_item i WHERE o.order_id = i.order_id`.
      *
      * @throws SQLException An exception that provides information on a 
database access error or other errors
      */
     public void processSuccessInClickHouse() throws SQLException {
-        Collection<Long> orderIds = insertData(Statement.NO_GENERATED_KEYS);
-        assertQueryInClickHouse();
+        Collection<Long> orderIds = insertDataWithoutGeneratedKeys();
+        assertQueryLoose();
         deleteDataInClickHouse(orderIds);
         assertTrue(orderRepository.selectAll().isEmpty());
         assertTrue(orderItemRepository.selectAll().isEmpty());
         assertTrue(addressRepository.selectAll().isEmpty());
     }
     
-    private void assertQueryInClickHouse() throws SQLException {
-        Collection<Order> orders = orderRepository.selectAll();
-        
assertThat(orders.stream().map(Order::getOrderId).collect(Collectors.toList()), 
not(empty()));
-        
assertThat(orders.stream().map(Order::getOrderType).collect(Collectors.toList()),
-                containsInAnyOrder(0, 1, 0, 1, 0, 1, 0, 1, 0, 1));
-        
assertThat(orders.stream().map(Order::getUserId).collect(Collectors.toList()),
-                containsInAnyOrder(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
-        
assertThat(orders.stream().map(Order::getAddressId).collect(Collectors.toList()),
-                containsInAnyOrder(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L));
-        
assertThat(orders.stream().map(Order::getStatus).collect(Collectors.toList()),
-                is(IntStream.range(1, 11).mapToObj(i -> 
"INSERT_TEST").collect(Collectors.toList())));
-        Collection<OrderItem> orderItems = orderItemRepository.selectAll();
-        
assertThat(orderItems.stream().map(OrderItem::getOrderItemId).collect(Collectors.toList()),
 not(empty()));
-        
assertThat(orderItems.stream().map(OrderItem::getOrderId).collect(Collectors.toList()),
 not(empty()));
-        
assertThat(orderItems.stream().map(OrderItem::getUserId).collect(Collectors.toList()),
-                containsInAnyOrder(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
-        
assertThat(orderItems.stream().map(OrderItem::getPhone).collect(Collectors.toList()),
-                is(IntStream.range(1, 11).mapToObj(i -> 
"13800000001").collect(Collectors.toList())));
-        
assertThat(orderItems.stream().map(OrderItem::getStatus).collect(Collectors.toList()),
-                is(IntStream.range(1, 11).mapToObj(i -> 
"INSERT_TEST").collect(Collectors.toList())));
-        assertThat(new HashSet<>(addressRepository.selectAll()),
-                is(LongStream.range(1L, 11L).mapToObj(each -> new 
Address(each, "address_test_" + each)).collect(Collectors.toSet())));
-    }
-    
-    private void deleteDataInClickHouse(final Collection<Long> orderIds) 
throws SQLException {
-        long count = 1L;
-        for (Long each : orderIds) {
-            orderRepository.deleteInClickHouse(each);
-            orderItemRepository.deleteInClickHouse(each);
-            addressRepository.deleteInClickHouse(count++);
-        }
-    }
-    
     /**
      * Process success in Hive.
      * Hive has not fully supported BEGIN, COMMIT, and ROLLBACK. Refer to <a 
href="https://cwiki.apache.org/confluence/display/Hive/Hive+Transactions";>Hive 
Transactions</a>.
      * So ShardingSphere should not use {@link 
OrderItemRepository#assertRollbackWithTransactions()}
-     * TODO It looks like HiveServer2 insert statements are inserted out of 
order. Waiting for further investigation.
-     *  The result of the insert is not currently asserted.
+     * TODO The current ShardingSphere parsing of HiveServer2's `INNER JOIN` 
syntax has shortcomings,
+     *  and it return incorrect query results for SQL statements such as 
`SELECT i.* FROM t_order o, t_order_item i WHERE o.order_id = i.order_id`.

Review Comment:
   Fixed.



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