mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 12:22:12 +00:00
Merge pull request #73082 from Avogar/fix-tuple-duplicate-json-key
Check for duplicate JSON keys during Tuple parsing
This commit is contained in:
commit
66eecb112f
@ -400,6 +400,9 @@ ReturnType SerializationTuple::deserializeTupleJSONImpl(IColumn & column, ReadBu
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (seen_elements[element_pos])
|
||||||
|
throw Exception(ErrorCodes::INCORRECT_DATA, "JSON object contains duplicate key '{}'", name);
|
||||||
|
|
||||||
seen_elements[element_pos] = 1;
|
seen_elements[element_pos] = 1;
|
||||||
auto & element_column = extractElementColumn(column, element_pos);
|
auto & element_column = extractElementColumn(column, element_pos);
|
||||||
|
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
a Tuple(\n b Nullable(String))
|
||||||
|
a Tuple(\n b Nullable(String))
|
@ -0,0 +1,9 @@
|
|||||||
|
select * from format(JSONEachRow, 'a Tuple(b UInt32)', '{"a" : {"b" : 1, "b" : 2}}'); -- {serverError INCORRECT_DATA}
|
||||||
|
select * from format(JSONEachRow, '{"a" : {"b" : 1, "b" : 2}}'); -- {serverError INCORRECT_DATA}
|
||||||
|
select * from format(JSONEachRow, '{"a" : {"b" : 1, "b" : 2, "b" : 3}, "c" : 42}'); -- {serverError INCORRECT_DATA}
|
||||||
|
set input_format_json_use_string_type_for_ambiguous_paths_in_named_tuples_inference_from_objects=1;
|
||||||
|
desc format(JSONEachRow, '{"a" : {"b" : 1, "b" : "Hello"}}');
|
||||||
|
select * from format(JSONEachRow, '{"a" : {"b" : 1, "b" : "Hello"}}'); -- {serverError INCORRECT_DATA}
|
||||||
|
desc format(JSONEachRow, '{"a" : {"b" : 1, "b" : {"c" : "Hello"}}}');
|
||||||
|
select * from format(JSONEachRow, '{"a" : {"b" : 1, "b" : {"c" : "Hello"}}}'); -- {serverError INCORRECT_DATA}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user