diff --git a/src/Processors/QueryPlan/AddingMissedStep.cpp b/src/Processors/QueryPlan/AddingMissedStep.cpp index d354405b5ac..359d0d46a87 100644 --- a/src/Processors/QueryPlan/AddingMissedStep.cpp +++ b/src/Processors/QueryPlan/AddingMissedStep.cpp @@ -11,7 +11,7 @@ static ITransformingStep::Traits getTraits() return ITransformingStep::Traits { { - .preserves_distinct_columns = true, + .preserves_distinct_columns = false, /// TODO: check if true later. .returns_single_stream = false, .preserves_number_of_streams = true, .preserves_sorting = true, diff --git a/src/Processors/QueryPlan/ExpressionStep.cpp b/src/Processors/QueryPlan/ExpressionStep.cpp index 6e148909bed..f7ca0a972dc 100644 --- a/src/Processors/QueryPlan/ExpressionStep.cpp +++ b/src/Processors/QueryPlan/ExpressionStep.cpp @@ -109,7 +109,6 @@ JoinStep::JoinStep(const DataStream & input_stream_, JoinPtr join_) getJoinTraits()) , join(std::move(join_)) { - updateDistinctColumns(output_stream->header, output_stream->distinct_columns); } void JoinStep::transformPipeline(QueryPipeline & pipeline) diff --git a/src/Processors/QueryPlan/ITransformingStep.cpp b/src/Processors/QueryPlan/ITransformingStep.cpp index 7ae2dd4284f..cb27bf38278 100644 --- a/src/Processors/QueryPlan/ITransformingStep.cpp +++ b/src/Processors/QueryPlan/ITransformingStep.cpp @@ -55,9 +55,9 @@ void ITransformingStep::updateDistinctColumns(const Block & res_header, NameSet if (distinct_columns.empty()) return; - for (const auto & column : res_header) + for (const auto & column : distinct_columns) { - if (distinct_columns.count(column.name) == 0) + if (!res_header.has(column)) { distinct_columns.clear(); break;