mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Fix segfault in Avro
This commit is contained in:
parent
a142b7c55e
commit
c5ea4b1bc0
@ -391,20 +391,27 @@ AvroRowOutputFormat::AvroRowOutputFormat(
|
||||
|
||||
AvroRowOutputFormat::~AvroRowOutputFormat() = default;
|
||||
|
||||
void AvroRowOutputFormat::writePrefix()
|
||||
void AvroRowOutputFormat::createFileWriter()
|
||||
{
|
||||
// we have to recreate avro::DataFileWriterBase object due to its interface limitations
|
||||
file_writer_ptr = std::make_unique<avro::DataFileWriterBase>(
|
||||
std::make_unique<OutputStreamWriteBufferAdapter>(out),
|
||||
serializer.getSchema(),
|
||||
settings.avro.output_sync_interval,
|
||||
getCodec(settings.avro.output_codec));
|
||||
}
|
||||
|
||||
void AvroRowOutputFormat::writePrefix()
|
||||
{
|
||||
// we have to recreate avro::DataFileWriterBase object due to its interface limitations
|
||||
createFileWriter();
|
||||
|
||||
file_writer_ptr->syncIfNeeded();
|
||||
}
|
||||
|
||||
void AvroRowOutputFormat::write(const Columns & columns, size_t row_num)
|
||||
{
|
||||
if (!file_writer_ptr)
|
||||
createFileWriter();
|
||||
file_writer_ptr->syncIfNeeded();
|
||||
serializer.serializeRow(columns, row_num, file_writer_ptr->encoder());
|
||||
file_writer_ptr->incr();
|
||||
|
@ -58,6 +58,8 @@ private:
|
||||
virtual void writePrefix() override;
|
||||
virtual void writeSuffix() override;
|
||||
|
||||
void createFileWriter();Z
|
||||
|
||||
FormatSettings settings;
|
||||
AvroSerializer serializer;
|
||||
std::unique_ptr<avro::DataFileWriterBase> file_writer_ptr;
|
||||
|
1
tests/queries/0_stateless/02168_avro_bug.reference
Normal file
1
tests/queries/0_stateless/02168_avro_bug.reference
Normal file
@ -0,0 +1 @@
|
||||
OK
|
4
tests/queries/0_stateless/02168_avro_bug.sql
Normal file
4
tests/queries/0_stateless/02168_avro_bug.sql
Normal file
@ -0,0 +1,4 @@
|
||||
insert into table function file('data.avro', 'Avro', 'x UInt64') select * from numbers(10);
|
||||
insert into table function file('data.avro', 'Avro', 'x UInt64') select * from numbers(10);
|
||||
insert into table function file('data.avro', 'Avro', 'x UInt64') select * from numbers(10);
|
||||
select 'OK';
|
Loading…
Reference in New Issue
Block a user