diff --git a/dbms/src/Processors/Executors/TreeExecutorBlockInputStream.cpp b/dbms/src/Processors/Executors/TreeExecutorBlockInputStream.cpp index f95425ecf43..c07499b28dc 100644 --- a/dbms/src/Processors/Executors/TreeExecutorBlockInputStream.cpp +++ b/dbms/src/Processors/Executors/TreeExecutorBlockInputStream.cpp @@ -259,7 +259,7 @@ void TreeExecutorBlockInputStream::initRowsBeforeLimit() } } - if (!rows_before_limit_at_least && (!limit_transforms.empty() && !sources.empty())) + if (!rows_before_limit_at_least && (!limit_transforms.empty() || !sources.empty())) { rows_before_limit_at_least = std::make_shared(); diff --git a/dbms/src/Processors/QueryPipeline.cpp b/dbms/src/Processors/QueryPipeline.cpp index 6b2ee284c2a..60ea824ad5c 100644 --- a/dbms/src/Processors/QueryPipeline.cpp +++ b/dbms/src/Processors/QueryPipeline.cpp @@ -622,7 +622,7 @@ void QueryPipeline::initRowsBeforeLimit() } } - if (!rows_before_limit_at_least && (!limits.empty() && !sources.empty())) + if (!rows_before_limit_at_least && (!limits.empty() || !sources.empty())) { rows_before_limit_at_least = std::make_shared();