mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-19 16:20:50 +00:00
Merge pull request #67687 from Avogar/fix-variant-as-common-type
Fix variant as common type in if function with Tuples, Maps and incompatible integers
This commit is contained in:
commit
c64f060496
@ -1233,6 +1233,12 @@ public:
|
||||
throw Exception(ErrorCodes::ILLEGAL_COLUMN, "Illegal column {} of first argument of function {}. "
|
||||
"Must be ColumnUInt8 or ColumnConstUInt8.", arg_cond.column->getName(), getName());
|
||||
|
||||
/// If result is Variant, always use generic implementation.
|
||||
/// Using typed implementations may lead to incorrect result column type when
|
||||
/// resulting Variant is created by use_variant_when_no_common_type.
|
||||
if (isVariant(result_type))
|
||||
return executeGeneric(cond_col, arguments, input_rows_count, use_variant_when_no_common_type);
|
||||
|
||||
auto call = [&](const auto & types) -> bool
|
||||
{
|
||||
using Types = std::decay_t<decltype(types)>;
|
||||
|
@ -0,0 +1,8 @@
|
||||
0 Variant(Int64, UInt64)
|
||||
1 Variant(Int64, UInt64)
|
||||
0 Variant(Int32, UInt64)
|
||||
1 Variant(Int32, UInt64)
|
||||
0 Variant(Int16, UInt64)
|
||||
1 Variant(Int16, UInt64)
|
||||
0 Variant(Int8, UInt64)
|
||||
1 Variant(Int8, UInt64)
|
@ -0,0 +1,8 @@
|
||||
set use_variant_as_common_type = 1;
|
||||
set allow_experimental_variant_type = 1;
|
||||
|
||||
SELECT if(number % 2, number::Int64, number::UInt64) as res, toTypeName(res) FROM numbers(2);
|
||||
SELECT if(number % 2, number::Int32, number::UInt64) as res, toTypeName(res) FROM numbers(2);
|
||||
SELECT if(number % 2, number::Int16, number::UInt64) as res, toTypeName(res) FROM numbers(2);
|
||||
SELECT if(number % 2, number::Int8, number::UInt64) as res, toTypeName(res) FROM numbers(2);
|
||||
|
@ -0,0 +1,10 @@
|
||||
('0') Variant(Tuple(String), Tuple(\n number UInt64))
|
||||
(1) Variant(Tuple(String), Tuple(\n number UInt64))
|
||||
('2') Variant(Tuple(String), Tuple(\n number UInt64))
|
||||
(3) Variant(Tuple(String), Tuple(\n number UInt64))
|
||||
('4') Variant(Tuple(String), Tuple(\n number UInt64))
|
||||
{'0':'0'} Variant(Map(String, String), Map(UInt64, UInt64))
|
||||
{1:1} Variant(Map(String, String), Map(UInt64, UInt64))
|
||||
{'2':'2'} Variant(Map(String, String), Map(UInt64, UInt64))
|
||||
{3:3} Variant(Map(String, String), Map(UInt64, UInt64))
|
||||
{'4':'4'} Variant(Map(String, String), Map(UInt64, UInt64))
|
@ -0,0 +1,7 @@
|
||||
set use_variant_as_common_type = 1;
|
||||
set allow_experimental_variant_type = 1;
|
||||
|
||||
SELECT if(number % 2, tuple(number), tuple(toString(number))) as res, toTypeName(res) FROM numbers(5);
|
||||
SELECT if(number % 2, map(number, number), map(toString(number), toString(number))) as res, toTypeName(res) FROM numbers(5);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user