From a61b7f2326f78fd4c61797451708d21a4874c946 Mon Sep 17 00:00:00 2001 From: vdimir Date: Mon, 12 Jul 2021 18:00:55 +0300 Subject: [PATCH] Add reqired right keys to join totals block --- src/Interpreters/join_common.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Interpreters/join_common.cpp b/src/Interpreters/join_common.cpp index 5548667e1a7..dd221b94808 100644 --- a/src/Interpreters/join_common.cpp +++ b/src/Interpreters/join_common.cpp @@ -329,8 +329,12 @@ void joinTotals(const Block & totals, const Block & columns_to_add, const TableJ if (Block totals_without_keys = totals) { + const auto & required_right = table_join.requiredRightKeys(); for (const auto & name : table_join.keyNamesRight()) - totals_without_keys.erase(totals_without_keys.getPositionByName(name)); + { + if (!required_right.contains(name)) + totals_without_keys.erase(totals_without_keys.getPositionByName(name)); + } for (auto & col : totals_without_keys) {