allow empty header in RemoteBlockOutputStream #3411

The bug with inserts to Distributed tables was introduced in https://github.com/yandex/ClickHouse/pull/3171
It added a workaround specifically for inserting in the Native format without specifying the list of columns.
Native (as opposed to other formats) historically supports this. To signal that the input block structure
shouldn't conform to any fixed header in this case, the remote server started sending empty header block.
This commit adds support for empty headers to RemoteBlockOutputStream.
This commit is contained in:
Alexey Zatelepin 2018-10-26 18:26:07 +03:00
parent a54dff25aa
commit e4e38f71e1

View File

@ -33,9 +33,6 @@ RemoteBlockOutputStream::RemoteBlockOutputStream(Connection & connection_, const
if (Protocol::Server::Data == packet.type)
{
header = packet.block;
if (!header)
throw Exception("Logical error: empty block received as table structure", ErrorCodes::LOGICAL_ERROR);
break;
}
else if (Protocol::Server::Exception == packet.type)
@ -58,7 +55,8 @@ RemoteBlockOutputStream::RemoteBlockOutputStream(Connection & connection_, const
void RemoteBlockOutputStream::write(const Block & block)
{
assertBlocksHaveEqualStructure(block, header, "RemoteBlockOutputStream");
if (header)
assertBlocksHaveEqualStructure(block, header, "RemoteBlockOutputStream");
try
{