Call writePrefix() from ctor in SinkToOutputStream

This will fix lack of headers for the following formats if there are
zero rows:
- TSVWithNames
- CSVWithNames
- TSVWithNamesAndTypes
This commit is contained in:
Azat Khuzhin 2020-08-11 00:51:53 +03:00
parent e43f49edfb
commit 72205cd326
2 changed files with 1 additions and 6 deletions

View File

@ -8,15 +8,11 @@ SinkToOutputStream::SinkToOutputStream(BlockOutputStreamPtr stream_)
: ISink(stream_->getHeader()) : ISink(stream_->getHeader())
, stream(std::move(stream_)) , stream(std::move(stream_))
{ {
stream->writePrefix();
} }
void SinkToOutputStream::consume(Chunk chunk) void SinkToOutputStream::consume(Chunk chunk)
{ {
if (!initialized)
stream->writePrefix();
initialized = true;
stream->write(getPort().getHeader().cloneWithColumns(chunk.detachColumns())); stream->write(getPort().getHeader().cloneWithColumns(chunk.detachColumns()));
} }

View File

@ -22,7 +22,6 @@ protected:
private: private:
BlockOutputStreamPtr stream; BlockOutputStreamPtr stream;
bool initialized = false;
}; };
} }