mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-02 20:42:04 +00:00
Edit reverse order
This commit is contained in:
parent
c8d4952702
commit
6c779e63b0
@ -1463,6 +1463,16 @@ void InterpreterSelectQuery::executeOrder(Pipeline & pipeline, SelectQueryInfo &
|
||||
}
|
||||
}
|
||||
|
||||
query_info.do_not_steal_task = false;
|
||||
query_info.read_in_pk_order = true;
|
||||
if (order_direction == -1)
|
||||
{
|
||||
query_info.read_in_reverse_order = true;
|
||||
pipeline.transform([&](auto & stream)
|
||||
{
|
||||
stream = std::make_shared<ReverseBlockInputStream>(stream);
|
||||
});
|
||||
}
|
||||
if (need_sorting)
|
||||
{
|
||||
if (!prefix_order_descr.empty())
|
||||
@ -1494,16 +1504,6 @@ void InterpreterSelectQuery::executeOrder(Pipeline & pipeline, SelectQueryInfo &
|
||||
}
|
||||
}
|
||||
|
||||
// in order to read blocks in fixed order
|
||||
query_info.do_not_steal_task = true;
|
||||
query_info.read_in_pk_order = true;
|
||||
if (order_direction == -1)
|
||||
{
|
||||
pipeline.transform([&](auto & stream)
|
||||
{
|
||||
stream = std::make_shared<ReverseBlockInputStream>(stream);
|
||||
});
|
||||
}
|
||||
executeUnion(pipeline);
|
||||
pipeline.firstStream() = std::make_shared<MergeSortingBlockInputStream>(
|
||||
pipeline.firstStream(), order_descr, settings.max_block_size, limit,
|
||||
|
@ -43,6 +43,7 @@ namespace std
|
||||
#include <DataStreams/NullBlockInputStream.h>
|
||||
#include <DataStreams/SummingSortedBlockInputStream.h>
|
||||
#include <DataStreams/ReplacingSortedBlockInputStream.h>
|
||||
#include <DataStreams/ReverseBlockInputStream.h>
|
||||
#include <DataStreams/AggregatingSortedBlockInputStream.h>
|
||||
#include <DataStreams/VersionedCollapsingSortedBlockInputStream.h>
|
||||
#include <DataTypes/DataTypesNumber.h>
|
||||
@ -839,7 +840,11 @@ BlockInputStreams MergeTreeDataSelectExecutor::spreadMarkRangesAmongStreamsPKOrd
|
||||
|
||||
for (size_t part_index = 0; part_index < parts.size(); ++part_index)
|
||||
{
|
||||
RangesInDataPart & part = parts[part_index];
|
||||
size_t index = part_index;
|
||||
if (query_info.read_in_reverse_order)
|
||||
index = parts.size() - part_index - 1;
|
||||
|
||||
RangesInDataPart & part = parts[index];
|
||||
|
||||
BlockInputStreamPtr source_stream = std::make_shared<MergeTreeSelectBlockInputStream>(
|
||||
data, part.data_part, max_block_size, settings.preferred_block_size_bytes,
|
||||
|
@ -55,6 +55,7 @@ struct SelectQueryInfo
|
||||
/// each of them will read data in sorted by sorting key order.
|
||||
bool do_not_steal_task = false;
|
||||
bool read_in_pk_order = false;
|
||||
bool read_in_reverse_order = false;
|
||||
|
||||
/// Prepared sets are used for indices by storage engine.
|
||||
/// Example: x IN (1, 2, 3)
|
||||
|
Loading…
Reference in New Issue
Block a user