Update LimitTransform.

This commit is contained in:
Nikolai Kochetov 2020-03-12 18:52:27 +03:00
parent 75185e5b40
commit 4b0cac25d1

View File

@ -92,9 +92,23 @@ IProcessor::Status LimitTransform::prepare(
for (auto pos : updated_output_ports)
process_pair(pos);
/// All ports are finished. It may happen even before we reached the limit (has less data then limit).
if (num_finished_port_pairs == input_ports.size())
return Status::Finished;
/// If we reached limit for some port, then close others. Otherwise some sources may infinitely read data.
/// Example: SELECT * FROM system.numbers_mt WHERE number = 1000000 LIMIT 1
if ((rows_read >= offset + limit) && !previous_row_chunk && !always_read_till_end)
{
for (auto & input : inputs)
input.close();
for (auto & output : outputs)
output.finish();
return Status::Finished;
}
if (has_full_port)
return Status::PortFull;