Make grouping never return low cardinality

This commit is contained in:
Raúl Marín 2024-05-06 14:36:04 +02:00
parent c932d26799
commit 8cdaa1a32a
2 changed files with 19 additions and 0 deletions

View File

@ -47,6 +47,10 @@ public:
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; }
/// Change it to never return LowCardinality, making it consistent when using groupingForRollup / groupingForforCube
/// with __grouping_set
bool canBeExecutedOnLowCardinalityDictionary() const override { return false; }
DataTypePtr getReturnTypeImpl(const DataTypes & /*arguments*/) const override
{
return std::make_shared<DataTypeUInt64>();

View File

@ -54,3 +54,18 @@ GROUP BY
WITH ROLLUP
ORDER BY multiIf(d = 0, key_a, NULL) ASC
FORMAT Null;
SELECT grouping(key_a) + grouping(key_b) AS d
FROM
(
SELECT
rand() % 10 AS key_a,
rand(toLowCardinality(1)) % 5 AS key_b,
number
FROM numbers(100)
)
GROUP BY
key_a,
key_b
WITH ROLLUP
FORMAT Null;