Fix unimplemented serialization error and update reference file

This commit is contained in:
Blargian 2024-05-14 21:55:56 +02:00
parent 3fb45ff176
commit 467366af99
2 changed files with 32 additions and 3 deletions

View File

@ -319,7 +319,7 @@ namespace
data_types.push_back(variant_type);
type_indexes.insert(TypeIndex::Variant);
// push it back again
// make the second type variant as well
data_types.push_back(variant_type);
type_indexes.insert(TypeIndex::Variant);
}
@ -669,7 +669,6 @@ namespace
if (settings.json.infer_variant_from_multitype_array)
{
transformVariant(data_types, type_indexes);
return;
}
/// Convert numbers inferred from strings back to strings if needed.
@ -703,7 +702,6 @@ namespace
if (settings.json.infer_variant_from_multitype_array)
{
transformVariant(data_types, type_indexes);
return;
}
/// Convert JSON tuples with same nested types to arrays.
@ -1440,6 +1438,15 @@ void transformFinalInferredJSONTypeIfNeededImpl(DataTypePtr & data_type, const F
return;
}
if (const auto * variant_type = typeid_cast<const DataTypeVariant *>(data_type.get()))
{
auto nested_types = variant_type->getVariants();
for (auto & nested_type : nested_types)
transformFinalInferredJSONTypeIfNeededImpl(nested_type, settings, json_info, remain_nothing_types);
data_type = std::make_shared<DataTypeVariant>(nested_types);
return;
}
}
void transformFinalInferredJSONTypeIfNeeded(DataTypePtr & data_type, const FormatSettings & settings, JSONInferenceInfo * json_info)

View File

@ -0,0 +1,22 @@
┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ arr ┃ toTypeName(arr) ┃
┡━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
1. │ [1,'Hello',(32)] │ Array(Variant(Int64, String, Tuple(…│
│ │… a Int64))) │
└──────────────────┴─────────────────────────────────────┘
┏━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ x ┃ toTypeName(x) ┃
┡━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━┩
1. │ 42 │ Variant(Int64, String) │
├───────┼────────────────────────┤
2. │ Hello │ Variant(Int64, String) │
└───────┴────────────────────────┘
┏━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ x ┃ toTypeName(x) ┃
┡━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
1. │ [1,2,3] │ Variant(Array(Int64), Tuple(…│
│ │… a Int64)) │
├─────────┼──────────────────────────────┤
2. │ (42) │ Variant(Array(Int64), Tuple(…│
│ │… a Int64)) │
└─────────┴──────────────────────────────┘