Skip to content

Error result of Grouping set when colocate is enable #5909

@EmmyMiao87

Description

@EmmyMiao87

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"
);
  1. load data
  2. open colocate session variables
set disable_colocate_plan = false
  1. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/colocatedIssues or PRs related to colocated tablesarea/plannerIssues or PRs related to the query plannerkind/fixCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions