mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Merge pull request #62059 from ClickHouse/fix-type-after-IfChainToMultiIfPass
Ignore IfChainToMultiIfPass if returned type changed.
This commit is contained in:
commit
dc45666b4f
@ -65,6 +65,12 @@ public:
|
||||
auto multi_if_function = std::make_shared<FunctionNode>("multiIf");
|
||||
multi_if_function->getArguments().getNodes() = std::move(multi_if_arguments);
|
||||
multi_if_function->resolveAsFunction(multi_if_function_ptr->build(multi_if_function->getArgumentColumns()));
|
||||
|
||||
/// Ignore if returned type changed.
|
||||
/// Example : SELECT now64(if(Null, NULL, if(Null, nan, toFloat64(number))), Null) FROM numbers(2)
|
||||
if (!multi_if_function->getResultType()->equals(*function_node->getResultType()))
|
||||
return;
|
||||
|
||||
node = std::move(multi_if_function);
|
||||
}
|
||||
|
||||
|
@ -2,3 +2,5 @@ SELECT if(number = 1, \'hello\', if(number = 2, \'world\', \'xyz\'))
|
||||
FROM numbers(10)
|
||||
SELECT multiIf(number = 1, \'hello\', number = 2, \'world\', \'xyz\')
|
||||
FROM numbers(10)
|
||||
\N
|
||||
\N
|
||||
|
@ -3,3 +3,6 @@ SET optimize_if_chain_to_multiif = 0;
|
||||
EXPLAIN SYNTAX SELECT number = 1 ? 'hello' : (number = 2 ? 'world' : 'xyz') FROM numbers(10);
|
||||
SET optimize_if_chain_to_multiif = 1;
|
||||
EXPLAIN SYNTAX SELECT number = 1 ? 'hello' : (number = 2 ? 'world' : 'xyz') FROM numbers(10);
|
||||
|
||||
-- fuzzed
|
||||
SELECT now64(if(Null, NULL, if(Null, nan, toFloat64(number))), Null) FROM numbers(2);
|
||||
|
Loading…
Reference in New Issue
Block a user