diff --git a/src/Processors/QueryPlan/DistinctStep.cpp b/src/Processors/QueryPlan/DistinctStep.cpp index 323ef0bbdab..f903fc973ad 100644 --- a/src/Processors/QueryPlan/DistinctStep.cpp +++ b/src/Processors/QueryPlan/DistinctStep.cpp @@ -26,13 +26,14 @@ static bool checkColumnsAlreadyDistinct(const Names & columns, const NameSet & d static ITransformingStep::Traits getTraits(bool pre_distinct, bool already_distinct_columns) { + const bool preserves_number_of_streams = pre_distinct || already_distinct_columns; return ITransformingStep::Traits { { .preserves_distinct_columns = already_distinct_columns, /// Will be calculated separately otherwise .returns_single_stream = !pre_distinct && !already_distinct_columns, - .preserves_number_of_streams = pre_distinct || already_distinct_columns, - .preserves_sorting = true, /// Sorting is preserved indeed because of implementation. + .preserves_number_of_streams = preserves_number_of_streams, + .preserves_sorting = preserves_number_of_streams, }, { .preserves_number_of_rows = false,