mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-19 12:52:37 +00:00
Merge pull request #73043 from Avogar/fix-json-parsing-format-settings
Use default format settings during JSON parsing to avoid broken deserialization
This commit is contained in:
commit
33b8948a5c
@ -1780,7 +1780,9 @@ private:
|
|||||||
|
|
||||||
paths_and_values_for_shared_data.emplace_back(current_path, "");
|
paths_and_values_for_shared_data.emplace_back(current_path, "");
|
||||||
WriteBufferFromString buf(paths_and_values_for_shared_data.back().second);
|
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;
|
return true;
|
||||||
@ -1807,6 +1809,12 @@ private:
|
|||||||
return false;
|
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_map<String, std::unique_ptr<JSONExtractTreeNode<JSONParser>>> typed_path_nodes;
|
||||||
std::unordered_set<String> paths_to_skip;
|
std::unordered_set<String> paths_to_skip;
|
||||||
std::vector<String> sorted_paths_to_skip;
|
std::vector<String> sorted_paths_to_skip;
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
{"a":[{"b":"42"}]}
|
@ -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;
|
Loading…
Reference in New Issue
Block a user