EmmyMiao87 opened a new issue #5909:
URL: https://github.com/apache/incubator-doris/issues/5909


   **Describe the bug**
   The result of following query is incorrect:
   ```
   SELECT k1, k2, SUM( k3 ) FROM table GROUP BY GROUPING SETS ( (k1, k2), (k1), 
(k2), ( ) ) order by k1, k2;
   ```
   The result number is incorrect.
   There are some duplicate rows that have not been aggregated.
   
   **To Reproduce**
   Steps to reproduce the behavior:
   1. create table , distributed by k1
   ```
   CREATE TABLE `table` (
     `k1` tinyint(4) NULL COMMENT "",
     `k2` smallint(6) NULL COMMENT "",
     `k3` int(11) NULL COMMENT "",
     `k4` bigint(20) NULL COMMENT "",
     `k5` decimal(9, 3) NULL COMMENT "",
     `k6` char(5) NULL COMMENT "",
     `k10` date NULL COMMENT "",
     `k11` datetime NULL COMMENT "",
     `k7` varchar(20) NULL COMMENT "",
     `k8` double MAX NULL COMMENT "",
     `k9` float SUM NULL COMMENT ""
   ) ENGINE=OLAP
   AGGREGATE KEY(`k1`, `k2`, `k3`, `k4`, `k5`, `k6`, `k10`, `k11`, `k7`)
   COMMENT "OLAP"
   DISTRIBUTED BY HASH(`k1`) BUCKETS 5
   PROPERTIES (
   "replication_num" = "3",
   "in_memory" = "false",
   "storage_format" = "V2"
   );
   ```
   2. load data
   3. open colocate session variables
   ```
   set disable_colocate_plan = false
   ```
   4. query, the answer is incorrect
   ```
   SELECT k1, k2, SUM( k3 ) FROM table GROUP BY GROUPING SETS ( (k1, k2), (k1), 
(k2), ( ) ) order by k1, k2
   ```
   
   **Expected behavior**
   the correct answer should be same as the answer of query:
   ```
   SELECT * FROM\n                (SELECT k1 as k1, k2 as k2, SUM( k3 ) FROM 
test_query_qa.baseall GROUP BY k1, k2 UNION\n                 SELECT k1, null, 
SUM( k3 ) FROM test_query_qa.baseall GROUP BY k1 UNION\n                 SELECT 
null, k2, SUM( k3 ) FROM test_query_qa.baseall GROUP BY k2 UNION\n              
   SELECT null, null, SUM( k3 )FROM test_query_qa.baseall\n                ) t 
ORDER BY k1, k2
   ```
   
   After colocate aggregation 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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to