mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Fix insertion of incomplete type into Dynamic during deserialization
This commit is contained in:
parent
a7d0a5991e
commit
92a4f4a02a
@ -591,12 +591,14 @@ static void deserializeTextImpl(
|
||||
return;
|
||||
}
|
||||
|
||||
/// We cannot insert value with incomplete type, insert it as String.
|
||||
variant_type = std::make_shared<DataTypeString>();
|
||||
/// To be able to deserialize field as String with Quoted escaping rule, it should be quoted.
|
||||
if (escaping_rule == FormatSettings::EscapingRule::Quoted && (field.size() < 2 || field.front() != '\'' || field.back() != '\''))
|
||||
field = "'" + field + "'";
|
||||
}
|
||||
else if (dynamic_column.addNewVariant(variant_type, variant_type->getName()))
|
||||
|
||||
if (dynamic_column.addNewVariant(variant_type, variant_type->getName()))
|
||||
{
|
||||
auto discr = variant_info.variant_name_to_discriminator.at(variant_type->getName());
|
||||
deserializeVariant(dynamic_column.getVariantColumn(), dynamic_column.getVariantSerialization(variant_type), discr, *field_buf, deserialize_variant);
|
||||
|
@ -0,0 +1,5 @@
|
||||
[]
|
||||
[]
|
||||
[[]]
|
||||
[['saw']]
|
||||
['had',1]
|
@ -0,0 +1,11 @@
|
||||
SET allow_experimental_dynamic_type = 1;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (c0 Array(Dynamic)) ENGINE = MergeTree() ORDER BY tuple();
|
||||
INSERT INTO t1 (c0) VALUES ([]);
|
||||
INSERT INTO t1 (c0) VALUES ([[]]), (['had', 1]);
|
||||
INSERT INTO t1 (c0) VALUES ([['saw']]);
|
||||
INSERT INTO t1 (c0) VALUES ([]);
|
||||
OPTIMIZE TABLE t1 final;
|
||||
SELECT * FROM t1 ORDER BY ALL;
|
||||
DROP TABLE t1;
|
||||
|
Loading…
Reference in New Issue
Block a user