Fix empty output of arrow related formats

This commit is contained in:
hcz 2020-08-06 13:58:08 +08:00
parent d4266d9619
commit dadcca6c08
2 changed files with 17 additions and 9 deletions

View File

@ -43,13 +43,17 @@ void ArrowBlockOutputFormat::consume(Chunk chunk)
void ArrowBlockOutputFormat::finalize()
{
if (writer)
if (!writer)
{
auto status = writer->Close();
if (!status.ok())
throw Exception(ErrorCodes::UNKNOWN_EXCEPTION,
"Error while closing a table: {}", status.ToString());
const Block & header = getPort(PortKind::Main).getHeader();
consume(Chunk(header.columns(), 0));
}
auto status = writer->Close();
if (!status.ok())
throw Exception(ErrorCodes::UNKNOWN_EXCEPTION,
"Error while closing a table: {}", status.ToString());
}
void ArrowBlockOutputFormat::prepareWriter(const std::shared_ptr<arrow::Schema> & schema)

View File

@ -66,12 +66,16 @@ void ParquetBlockOutputFormat::consume(Chunk chunk)
void ParquetBlockOutputFormat::finalize()
{
if (file_writer)
if (!file_writer)
{
auto status = file_writer->Close();
if (!status.ok())
throw Exception{"Error while closing a table: " + status.ToString(), ErrorCodes::UNKNOWN_EXCEPTION};
const Block & header = getPort(PortKind::Main).getHeader();
consume(Chunk(header.columns(), 0));
}
auto status = file_writer->Close();
if (!status.ok())
throw Exception{"Error while closing a table: " + status.ToString(), ErrorCodes::UNKNOWN_EXCEPTION};
}
void registerOutputFormatProcessorParquet(FormatFactory & factory)