Fix: correct sort description for ReadFromMergeTree with read in order

optimization
This commit is contained in:
Igor Nikonov 2022-09-18 22:21:13 +00:00
parent 560bc2bc22
commit e888859396
2 changed files with 7 additions and 0 deletions

View File

@ -48,6 +48,8 @@ struct SortColumnDescription
bool with_fill;
FillColumnDescription fill_description;
SortColumnDescription() = default;
explicit SortColumnDescription(
const std::string & column_name_,
int direction_ = 1,

View File

@ -143,7 +143,12 @@ ReadFromMergeTree::ReadFromMergeTree(
{
auto const & settings = context->getSettingsRef();
if ((settings.optimize_read_in_order || settings.optimize_aggregation_in_order) && query_info.getInputOrderInfo())
{
output_stream->sort_scope = DataStream::SortScope::Stream;
const auto used_prefix_of_sorting_key_size = query_info.getInputOrderInfo()->used_prefix_of_sorting_key_size;
if (sort_description.size() > used_prefix_of_sorting_key_size)
sort_description.resize(used_prefix_of_sorting_key_size);
}
else
output_stream->sort_scope = DataStream::SortScope::Chunk;
}