diff --git a/dbms/src/Storages/MergeTree/MergeTreeRangeReader.cpp b/dbms/src/Storages/MergeTree/MergeTreeRangeReader.cpp index 4d30b7522f8..7e28f20891d 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeRangeReader.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeRangeReader.cpp @@ -428,7 +428,7 @@ MergeTreeRangeReader::ReadResult MergeTreeRangeReader::startReadingChain(size_t /// result.num_rows_read if the last granule in range also the last in part (so we have to adjust last granule). { size_t space_left = max_rows; - while (space_left && !stream.isFinished() && !ranges.empty()) + while (space_left && (!stream.isFinished() || !ranges.empty())) { if (stream.isFinished()) { diff --git a/dbms/src/Storages/MergeTree/MergeTreeRangeReader.h b/dbms/src/Storages/MergeTree/MergeTreeRangeReader.h index bcb78b8718c..59fb4c3deb8 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeRangeReader.h +++ b/dbms/src/Storages/MergeTree/MergeTreeRangeReader.h @@ -114,7 +114,7 @@ public: size_t getNumAddedRows() const { return num_added_rows; } /// The number of filtered rows at all steps in reading chain. size_t getNumFilteredRows() const { return num_filtered_rows; } - /// Filter you need to allply to newly-read columns in order to add them to block. + /// Filter you need to apply to newly-read columns in order to add them to block. const ColumnPtr & getFilter() const { return filter; } void addGranule(size_t num_rows);