diff --git a/src/Interpreters/HashJoin.cpp b/src/Interpreters/HashJoin.cpp index d02a2bf3e52..6baf7cda4f8 100644 --- a/src/Interpreters/HashJoin.cpp +++ b/src/Interpreters/HashJoin.cpp @@ -758,13 +758,7 @@ bool HashJoin::addJoinedBlock(const Block & source_block, bool check_limits) Block block = materializeBlock(source_block); size_t rows = block.rows(); - ColumnRawPtrMap all_key_columns; - { - Names all_key_names_right; - for (const auto & clause : table_join->getClauses()) - all_key_names_right.insert(all_key_names_right.end(), clause.key_names_right.begin(), clause.key_names_right.end()); - all_key_columns = JoinCommon::materializeColumnsInplaceMap(block, all_key_names_right); - } + ColumnRawPtrMap all_key_columns = JoinCommon::materializeColumnsInplaceMap(block, table_join->getAllNames(JoinTableSide::Right)); Block structured_block = structureRightBlock(block); size_t total_rows = 0; diff --git a/src/Interpreters/TableJoin.cpp b/src/Interpreters/TableJoin.cpp index d48d3293642..ce6103ec87d 100644 --- a/src/Interpreters/TableJoin.cpp +++ b/src/Interpreters/TableJoin.cpp @@ -71,7 +71,8 @@ bool forAllKeys(OnExpr & expressions, Func callback) if constexpr (std::is_same_v) assert(expr.key_names_left.size() == expr.key_names_right.size()); - for (size_t i = 0; i < expr.key_names_left.size(); ++i) + size_t sz = !std::is_same_v ? expr.key_names_left.size() : expr.key_names_right.size(); + for (size_t i = 0; i < sz; ++i) { bool cont; if constexpr (std::is_same_v)