Merge pull request #64638 from ClickHouse/analyzer-fix-rewrite-agg-with-if

Analyzer: Fix RewriteAggregateFunctionWithIfPass
This commit is contained in:
Dmitry Novik 2024-05-31 10:25:07 +00:00 committed by GitHub
commit dc2d5e0ec6
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);