Slightly better JSON type parsing

This commit is contained in:
avogar 2024-11-11 21:11:31 +00:00
parent d65f68f88e
commit 237a81ff8c
3 changed files with 13 additions and 1 deletions

View File

@ -1442,7 +1442,8 @@ public:
auto shared_variant_discr = column_dynamic.getSharedVariantDiscriminator();
auto insert_settings_with_no_type_conversion = insert_settings;
insert_settings_with_no_type_conversion.allow_type_conversion = false;
for (size_t i = 0; i != variant_info.variant_names.size(); ++i)
auto order = SerializationVariant::getVariantsDeserializeTextOrder(assert_cast<const DataTypeVariant &>(*variant_info.variant_type).getVariants());
for (size_t i : order)
{
if (i != shared_variant_discr)
{

View File

@ -0,0 +1,3 @@
Int64 42
Float64 42.42
Int64 43

View File

@ -0,0 +1,8 @@
set allow_experimental_json_type = 1;
drop table if exists test;
create table test (json JSON) engine=Memory;
insert into test format JSONAsObject {"a" : 42}, {"a" : 42.42}, {"a" : 43};
select dynamicType(json.a), json.a from test;
drop table test;