Fix nested JSON Objects schema inference

This commit is contained in:
avogar 2022-08-31 14:10:29 +00:00
parent 487100a4fd
commit acf87c1d10

View File

@ -218,7 +218,6 @@ namespace JSONUtils
{
auto object = field.getObject();
DataTypes value_types;
bool have_object_value = false;
for (const auto key_value_pair : object)
{
auto type = getDataTypeFromFieldImpl(key_value_pair.second, settings, numbers_parsed_from_json_strings);
@ -226,10 +225,7 @@ namespace JSONUtils
continue;
if (isObject(type))
{
have_object_value = true;
break;
}
return std::make_shared<DataTypeObject>("json", true);
value_types.push_back(type);
}
@ -242,7 +238,7 @@ namespace JSONUtils
for (size_t i = 1; i < value_types.size(); ++i)
are_types_equal &= value_types[i]->equals(*value_types[0]);
if (have_object_value || !are_types_equal)
if (!are_types_equal)
return std::make_shared<DataTypeObject>("json", true);
return std::make_shared<DataTypeMap>(std::make_shared<DataTypeString>(), value_types[0]);