Merge pull request #51807 from ClickHouse/check_not_empty_header_for_remote

Make sure that we don't attempt to serialize/deserialize block with 0 columns and non-zero rows
This commit is contained in:
robot-clickhouse-ci-1 2023-07-13 12:15:38 +02:00 committed by GitHub
commit 57c3941fa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -149,6 +149,9 @@ Block NativeReader::read()
rows = index_block_it->num_rows;
}
if (columns == 0 && !header && rows != 0)
throw Exception(ErrorCodes::INCORRECT_DATA, "Zero columns but {} rows in Native format.", rows);
for (size_t i = 0; i < columns; ++i)
{
if (use_index)
@ -290,6 +293,9 @@ Block NativeReader::read()
res.swap(tmp_res);
}
if (res.rows() != rows)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Row count mismatch after desirialization, got: {}, expected: {}", res.rows(), rows);
return res;
}