mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-19 16:20:50 +00:00
Fix unimplemented serialization error and update reference file
This commit is contained in:
parent
3fb45ff176
commit
467366af99
@ -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)
|
||||
|
22
tests/queries/0_stateless/03150_infer_type_variant.reference
Normal file
22
tests/queries/0_stateless/03150_infer_type_variant.reference
Normal 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)) │
|
||||
└─────────┴──────────────────────────────┘
|
Loading…
Reference in New Issue
Block a user