Merge pull request #64678 from ClickHouse/backport/24.3/64638

Backport #64638 to 24.3: Analyzer: Fix RewriteAggregateFunctionWithIfPass
This commit is contained in:
Dmitry Novik 2024-06-03 13:43:16 +02:00 committed by GitHub
commit e043937507
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 1 deletions

View File

@ -36,6 +36,10 @@ public:
if (!function_node || !function_node->isAggregateFunction())
return;
auto lower_name = Poco::toLower(function_node->getFunctionName());
if (lower_name.ends_with("if"))
return;
auto & function_arguments_nodes = function_node->getArguments().getNodes();
if (function_arguments_nodes.size() != 1)
return;
@ -44,7 +48,6 @@ public:
if (!if_node || if_node->getFunctionName() != "if")
return;
auto lower_name = Poco::toLower(function_node->getFunctionName());
auto if_arguments_nodes = if_node->getArguments().getNodes();
auto * first_const_node = if_arguments_nodes[1]->as<ConstantNode>();
auto * second_const_node = if_arguments_nodes[2]->as<ConstantNode>();

View File

@ -0,0 +1 @@
SELECT countIf(multiIf(number < 2, NULL, if(number = 4, 1, 0))) FROM numbers(5);