From de296ecc6399647aa0cb5b39a504fc55732d1082 Mon Sep 17 00:00:00 2001 From: lgbo-ustc Date: Thu, 27 Jun 2024 17:59:36 +0800 Subject: [PATCH] fixed: mismatched headers in broadcast join --- cpp-ch/local-engine/Parser/JoinRelParser.cpp | 23 ++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/cpp-ch/local-engine/Parser/JoinRelParser.cpp b/cpp-ch/local-engine/Parser/JoinRelParser.cpp index 58b156c3cf6e..9a3cc91baaa9 100644 --- a/cpp-ch/local-engine/Parser/JoinRelParser.cpp +++ b/cpp-ch/local-engine/Parser/JoinRelParser.cpp @@ -309,12 +309,27 @@ DB::QueryPlanPtr JoinRelParser::parseJoin(const substrait::JoinRel & join, DB::Q // Add a check to find error easily. if (storage_join) { - if(!blocksHaveEqualStructure(right_header_before_convert_step, right->getCurrentDataStream().header)) + bool is_col_names_changed = false; + const auto & current_right_header = right->getCurrentDataStream().header; + if (right_header_before_convert_step.columns() != current_right_header.columns()) + is_col_names_changed = true; + if (!is_col_names_changed) + { + for (size_t i = 0; i < right_header_before_convert_step.columns(); i++) + { + if (right_header_before_convert_step.getByPosition(i).name != current_right_header.getByPosition(i).name) + { + is_col_names_changed = true; + break; + } + } + } + if (is_col_names_changed) { throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR, "For broadcast join, we must not change the columns name in the right table.\nleft header:{},\nright header: {} -> {}", - left->getCurrentDataStream().header.dumpNames(), - right_header_before_convert_step.dumpNames(), - right->getCurrentDataStream().header.dumpNames()); + left->getCurrentDataStream().header.dumpStructure(), + right_header_before_convert_step.dumpStructure(), + right->getCurrentDataStream().header.dumpStructure()); } }