fix assertion in fuzzer

This commit is contained in:
Anton Popov 2022-10-03 14:44:33 +00:00
parent 6e61cf92f5
commit 8db899e550
3 changed files with 12 additions and 3 deletions

View File

@ -165,16 +165,23 @@ void SerializationObject<Parser>::serializeBinaryBulkStatePrefix(
throw Exception(ErrorCodes::NOT_IMPLEMENTED, throw Exception(ErrorCodes::NOT_IMPLEMENTED,
"DataTypeObject doesn't support serialization with non-trivial state"); "DataTypeObject doesn't support serialization with non-trivial state");
const auto & column_object = assert_cast<const ColumnObject &>(column);
if (!column_object.isFinalized())
{
auto finalized = column_object.cloneFinalized();
serializeBinaryBulkStatePrefix(*finalized, settings, state);
return;
}
settings.path.push_back(Substream::ObjectStructure); settings.path.push_back(Substream::ObjectStructure);
auto * stream = settings.getter(settings.path); auto * stream = settings.getter(settings.path);
if (!stream) if (!stream)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Missing stream for kind of binary serialization"); throw Exception(ErrorCodes::LOGICAL_ERROR, "Missing stream for kind of binary serialization");
writeIntBinary(static_cast<UInt8>(BinarySerializationKind::TUPLE), *stream);
const auto & column_object = assert_cast<const ColumnObject &>(column);
auto [tuple_column, tuple_type] = unflattenObjectToTuple(column_object); auto [tuple_column, tuple_type] = unflattenObjectToTuple(column_object);
writeIntBinary(static_cast<UInt8>(BinarySerializationKind::TUPLE), *stream);
writeStringBinary(tuple_type->getName(), *stream); writeStringBinary(tuple_type->getName(), *stream);
auto state_object = std::make_shared<SerializeStateObject>(); auto state_object = std::make_shared<SerializeStateObject>();

View File

@ -20,3 +20,4 @@ Tuple(k2 String, k3 String, k4 Int8)
{"arr":[1,{"y":1}]} {"arr":[1,{"y":1}]}
{"arr":[2,{"y":2}]} {"arr":[2,{"y":2}]}
{"arr":[{"x":"aaa","y":[1,2,3]}]} {"arr":[{"x":"aaa","y":[1,2,3]}]}
{"arr":[{"x":1}]}

View File

@ -32,3 +32,4 @@ SELECT * FROM values('arr Array(JSON)', '[\'{"x" : 1}\']') FORMAT JSONEachRow;
SELECT * FROM values('arr Map(String, JSON)', '{\'x\' : \'{"y" : 1}\', \'t\' : \'{"y" : 2}\'}') FORMAT JSONEachRow; SELECT * FROM values('arr Map(String, JSON)', '{\'x\' : \'{"y" : 1}\', \'t\' : \'{"y" : 2}\'}') FORMAT JSONEachRow;
SELECT * FROM values('arr Tuple(Int32, JSON)', '(1, \'{"y" : 1}\')', '(2, \'{"y" : 2}\')') FORMAT JSONEachRow; SELECT * FROM values('arr Tuple(Int32, JSON)', '(1, \'{"y" : 1}\')', '(2, \'{"y" : 2}\')') FORMAT JSONEachRow;
SELECT * FROM format(JSONEachRow, '{"arr" : [{"x" : "aaa", "y" : [1,2,3]}]}') FORMAT JSONEachRow; SELECT * FROM format(JSONEachRow, '{"arr" : [{"x" : "aaa", "y" : [1,2,3]}]}') FORMAT JSONEachRow;
SELECT * FROM values('arr Array(JSON)', '[\'{"x" : 1}\']') FORMAT JSONEachRow;