mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Fix possible segfault in schema inference for JSON formats
This commit is contained in:
parent
71dc0f0616
commit
348cae0d16
@ -255,6 +255,10 @@ struct JSONEachRowFieldsExtractor
|
||||
std::vector<Element> extract(const Element & element)
|
||||
{
|
||||
/// {..., "<column_name>" : <value>, ...}
|
||||
|
||||
if (!element.isObject())
|
||||
throw Exception(ErrorCodes::INCORRECT_DATA, "Root JSON value is not an object");
|
||||
|
||||
auto object = element.getObject();
|
||||
std::vector<Element> fields;
|
||||
fields.reserve(object.size());
|
||||
@ -287,6 +291,9 @@ struct JSONCompactEachRowFieldsExtractor
|
||||
std::vector<Element> extract(const Element & element)
|
||||
{
|
||||
/// [..., <value>, ...]
|
||||
if (!element.isArray())
|
||||
throw Exception(ErrorCodes::INCORRECT_DATA, "Root JSON value is not an array");
|
||||
|
||||
auto array = element.getArray();
|
||||
std::vector<Element> fields;
|
||||
fields.reserve(array.size());
|
||||
|
@ -0,0 +1,8 @@
|
||||
-- Tags: no-backward-compatibility-check:22.4.1.1
|
||||
|
||||
insert into function file('02268_data.jsonl', 'TSV') select 1;
|
||||
select * from file('02268_data.jsonl'); --{serverError CANNOT_EXTRACT_TABLE_STRUCTURE}
|
||||
|
||||
insert into function file('02268_data.jsonCompactEachRow', 'TSV') select 1;
|
||||
select * from file('02268_data.jsonCompactEachRow'); --{serverError CANNOT_EXTRACT_TABLE_STRUCTURE}
|
||||
|
Loading…
Reference in New Issue
Block a user