mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Better String to Variant(String) conversion
This commit is contained in:
parent
0d62307178
commit
fd58e4d08b
@ -4119,10 +4119,11 @@ private:
|
||||
};
|
||||
}
|
||||
|
||||
if (isStringOrFixedString(removeNullable(removeLowCardinality(from_type))))
|
||||
auto variant_discr_opt = to_variant.tryGetVariantDiscriminator(*removeNullableOrLowCardinalityNullable(from_type));
|
||||
/// Cast String to Variant through parsing if it's not Variant(String).
|
||||
if (isStringOrFixedString(removeNullable(removeLowCardinality(from_type))) && (!variant_discr_opt || to_variant.getVariants().size() > 1))
|
||||
return createStringToVariantWrapper();
|
||||
|
||||
auto variant_discr_opt = to_variant.tryGetVariantDiscriminator(*removeNullableOrLowCardinalityNullable(from_type));
|
||||
if (!variant_discr_opt)
|
||||
throw Exception(ErrorCodes::CANNOT_CONVERT_TYPE, "Cannot convert type {} to {}. Conversion to Variant allowed only for types from this Variant", from_type->getName(), to_variant.getName());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user