Fix the estimation of total rows for the numbers data source

This commit is contained in:
Alexey Milovidov 2024-07-24 07:45:24 +02:00
parent 385dabaa19
commit bc899ead26

View File

@ -596,12 +596,12 @@ Pipe ReadFromSystemNumbersStep::makePipe()
numbers_storage.step,
step_between_chunks);
if (numbers_storage.limit && i == 0)
if (end && i == 0)
{
auto rows_appr = itemCountInRange(numbers_storage.offset, *numbers_storage.limit, numbers_storage.step);
if (limit > 0 && limit < rows_appr)
rows_appr = query_info_limit;
source->addTotalRowsApprox(rows_appr);
UInt64 rows_approx = itemCountInRange(numbers_storage.offset, *end, numbers_storage.step);
if (limit > 0 && limit < rows_approx)
rows_approx = query_info_limit;
source->addTotalRowsApprox(rows_approx);
}
pipe.addSource(std::move(source));