mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
I ♥ group_by_use_nulls.
This commit is contained in:
parent
5e87ecf32e
commit
e5282bf39f
@ -6694,8 +6694,11 @@ void QueryAnalyzer::resolveGroupByNode(QueryNode & query_node_typed, IdentifierR
|
||||
{
|
||||
for (const auto & grouping_set : query_node_typed.getGroupBy().getNodes())
|
||||
{
|
||||
for (const auto & group_by_elem : grouping_set->as<ListNode>()->getNodes())
|
||||
for (auto & group_by_elem : grouping_set->as<ListNode>()->getNodes())
|
||||
{
|
||||
group_by_elem = group_by_elem->clone();
|
||||
scope.nullable_group_by_keys.insert(group_by_elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6713,8 +6716,15 @@ void QueryAnalyzer::resolveGroupByNode(QueryNode & query_node_typed, IdentifierR
|
||||
|
||||
if (scope.group_by_use_nulls)
|
||||
{
|
||||
for (const auto & group_by_elem : query_node_typed.getGroupBy().getNodes())
|
||||
for (auto & group_by_elem : query_node_typed.getGroupBy().getNodes())
|
||||
{
|
||||
/// Clone is needed cause aliases share subtrees.
|
||||
/// If not clone, a part of GROUP BY key could be replaced to nullable
|
||||
/// by replacing a part of alias from another subtree to nullable.
|
||||
/// See 03023_group_by_use_nulls_analyzer_crashes
|
||||
group_by_elem = group_by_elem->clone();
|
||||
scope.nullable_group_by_keys.insert(group_by_elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,3 +9,11 @@ SELECT tuple(number) AS x FROM numbers(10) GROUP BY GROUPING SETS (number) order
|
||||
SELECT ignore(toFixedString('Lambda as function parameter', 28), toNullable(28), ignore(8)), sum(marks) FROM system.parts WHERE database = currentDatabase() GROUP BY GROUPING SETS ((2)) FORMAT Null settings optimize_injective_functions_in_group_by=1, optimize_group_by_function_keys=1, group_by_use_nulls=1; -- { serverError ILLEGAL_AGGREGATION }
|
||||
|
||||
SELECT toLowCardinality(materialize('a' AS key)), 'b' AS value GROUP BY key WITH CUBE SETTINGS group_by_use_nulls = 1;
|
||||
|
||||
SELECT tuple(tuple(number)) AS x
|
||||
FROM numbers(10)
|
||||
GROUP BY (number, (toString(x), number))
|
||||
WITH CUBE
|
||||
SETTINGS group_by_use_nulls = 1 FORMAT Null;
|
||||
|
||||
SELECT tuple(number + 1) AS x FROM numbers(10) GROUP BY number + 1, toString(x) WITH CUBE settings group_by_use_nulls=1 FORMAT Null;
|
||||
|
Loading…
Reference in New Issue
Block a user