Use default format settings during JSON parsing to avoid broken deserialization

This commit is contained in:
avogar 2024-12-10 14:27:58 +00:00
parent e83921d2cb
commit b718b2ea88
3 changed files with 18 additions and 1 deletions

View File

@ -1780,7 +1780,9 @@ private:
paths_and_values_for_shared_data.emplace_back(current_path, "");
WriteBufferFromString buf(paths_and_values_for_shared_data.back().second);
dynamic_serialization->serializeBinary(*tmp_dynamic_column, 0, buf, format_settings);
/// Use default format settings for binary serialization. Non-default settings may change
/// the binary representation of the values and break the future deserialization.
dynamic_serialization->serializeBinary(*tmp_dynamic_column, 0, buf, getDefaultFormatSettings());
}
return true;
@ -1807,6 +1809,12 @@ private:
return false;
}
const FormatSettings & getDefaultFormatSettings() const
{
static const FormatSettings settings;
return settings;
}
std::unordered_map<String, std::unique_ptr<JSONExtractTreeNode<JSONParser>>> typed_path_nodes;
std::unordered_set<String> paths_to_skip;
std::vector<String> sorted_paths_to_skip;

View File

@ -0,0 +1,8 @@
set enable_json_type=1;
set output_format_binary_write_json_as_string=1;
drop table if exists test;
create table test (json JSON(max_dynamic_paths=0)) engine=Memory;
insert into test format JSONAsObject {"a" : [{"b" : 42}]};
select * from test;