kimmking edited a comment on issue #6658: URL: https://github.com/apache/shardingsphere/issues/6658#issuecomment-680671377
Case 1: shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/cases/dql/dataset/tbl/select_distinct_with_avg.xml The original sql ``` SELECT AVG(DISTINCT order_id) FROM t_order WHERE order_id < 1100 ``` convert to: ``` SELECT DISTINCT order_id AS AGGREGATION_DISTINCT_DERIVED_0 , order_id AS AVG_DERIVED_COUNT_0 , order_id AS AVG_DERIVED_SUM_0 FROM t_order_0 WHERE order_id < 1100 SELECT DISTINCT order_id AS AGGREGATION_DISTINCT_DERIVED_0 , order_id AS AVG_DERIVED_COUNT_0 , order_id AS AVG_DERIVED_SUM_0 FROM t_order_1 WHERE order_id < 1100 ...... ``` Rewriting result is wrong, it should be: ``` SELECT DISTINCT order_id AS AGGREGATION_DISTINCT_DERIVED_0 , COUNT(order_id) AS AVG_DERIVED_COUNT_0 , SUM(order_id) AS AVG_DERIVED_SUM_0 FROM t_order_0 WHERE order_id < 1100 GROUP BY order_id ORDER BY order_id; ``` There are two wrong rewriting: 1. Missing GROUP-BY and ORDER-BY 2. Missing COUNT and SUM ---------------------------------------------------------------- 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]
