mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Merge pull request #57622 from ClickHouse/vdimir/analyzer_multiif_logical_err
Analyzer: Fix logical error in MultiIfToIfPass
This commit is contained in:
commit
86bdd883f4
@ -33,8 +33,17 @@ public:
|
||||
if (function_node->getArguments().getNodes().size() != 3)
|
||||
return;
|
||||
|
||||
auto result_type = function_node->getResultType();
|
||||
function_node->resolveAsFunction(if_function_ptr->build(function_node->getArgumentColumns()));
|
||||
auto if_function_value = if_function_ptr->build(function_node->getArgumentColumns());
|
||||
if (!if_function_value->getResultType()->equals(*function_node->getResultType()))
|
||||
{
|
||||
/** We faced some corner case, when result type of `if` and `multiIf` are different.
|
||||
* For example, currently `if(NULL`, a, b)` returns type of `a` column,
|
||||
* but multiIf(NULL, a, b) returns supertypetype of `a` and `b`.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
function_node->resolveAsFunction(std::move(if_function_value));
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -1 +1,3 @@
|
||||
1
|
||||
9
|
||||
3
|
||||
|
@ -1 +1,3 @@
|
||||
SELECT sum(A) FROM (SELECT multiIf(1, 1, NULL) as A);
|
||||
SELECT sum(multiIf(number = NULL, 65536, 3)) FROM numbers(3);
|
||||
SELECT multiIf(NULL, 65536 :: UInt32, 3 :: Int32);
|
||||
|
Loading…
Reference in New Issue
Block a user