From acf87c1d10fb39291af387a2dd0bd22b5467b613 Mon Sep 17 00:00:00 2001 From: avogar Date: Wed, 31 Aug 2022 14:10:29 +0000 Subject: [PATCH] Fix nested JSON Objects schema inference --- src/Formats/JSONUtils.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Formats/JSONUtils.cpp b/src/Formats/JSONUtils.cpp index 895833abf4d..9aa0645f580 100644 --- a/src/Formats/JSONUtils.cpp +++ b/src/Formats/JSONUtils.cpp @@ -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("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("json", true); return std::make_shared(std::make_shared(), value_types[0]);