Skip to content

Commit

Permalink
Revert "[GLUTEN-6463][CH]refactor the code of parsing join parameters a…
Browse files Browse the repository at this point in the history
…pache#6485"

This reverts commit 2e908c0.
  • Loading branch information
yma11 committed Jul 19, 2024
1 parent b8f11be commit da1143a
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 173 deletions.
127 changes: 0 additions & 127 deletions cpp-ch/local-engine/Parser/AdvancedParametersParseUtil.cpp

This file was deleted.

37 changes: 0 additions & 37 deletions cpp-ch/local-engine/Parser/AdvancedParametersParseUtil.h

This file was deleted.

17 changes: 12 additions & 5 deletions cpp-ch/local-engine/Parser/CrossRelParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <Join/BroadCastJoinBuilder.h>
#include <Join/StorageJoinFromReadBuffer.h>
#include <Parser/SerializedPlanParser.h>
#include <Parser/AdvancedParametersParseUtil.h>
#include <Parsers/ASTIdentifier.h>
#include <Processors/QueryPlan/ExpressionStep.h>
#include <Processors/QueryPlan/FilterStep.h>
Expand All @@ -52,6 +51,17 @@ using namespace DB;

namespace local_engine
{
String parseCrossJoinOptimizationInfos(const substrait::CrossRel & join)
{
google::protobuf::StringValue optimization;
optimization.ParseFromString(join.advanced_extension().optimization().value());
String storage_join_key;
ReadBufferFromString in(optimization.value());
assertString("JoinParameters:", in);
assertString("buildHashTableId=", in);
readString(storage_join_key, in);
return storage_join_key;
}

std::shared_ptr<DB::TableJoin> createCrossTableJoin(substrait::CrossRel_JoinType join_type)
{
Expand Down Expand Up @@ -144,10 +154,7 @@ void CrossRelParser::renamePlanColumns(DB::QueryPlan & left, DB::QueryPlan & rig

DB::QueryPlanPtr CrossRelParser::parseJoin(const substrait::CrossRel & join, DB::QueryPlanPtr left, DB::QueryPlanPtr right)
{
google::protobuf::StringValue optimization_info;
optimization_info.ParseFromString(join.advanced_extension().optimization().value());
auto join_opt_info = JoinOptimizationInfo::parse(optimization_info.value());
const auto & storage_join_key = join_opt_info.storage_join_key;
auto storage_join_key = parseCrossJoinOptimizationInfos(join);
auto storage_join = BroadCastJoinBuilder::getJoin(storage_join_key) ;
renamePlanColumns(*left, *right, *storage_join);
auto table_join = createCrossTableJoin(join.type());
Expand Down
57 changes: 53 additions & 4 deletions cpp-ch/local-engine/Parser/JoinRelParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <Join/BroadCastJoinBuilder.h>
#include <Join/StorageJoinFromReadBuffer.h>
#include <Parser/SerializedPlanParser.h>
#include <Parser/AdvancedParametersParseUtil.h>
#include <Parsers/ASTIdentifier.h>
#include <Processors/QueryPlan/ExpressionStep.h>
#include <Processors/QueryPlan/FilterStep.h>
Expand All @@ -47,8 +46,60 @@ namespace ErrorCodes
extern const int BAD_ARGUMENTS;
}
}

struct JoinOptimizationInfo
{
bool is_broadcast = false;
bool is_smj = false;
bool is_null_aware_anti_join = false;
bool is_existence_join = false;
std::string storage_join_key;
};

using namespace DB;

JoinOptimizationInfo parseJoinOptimizationInfo(const substrait::JoinRel & join)
{
google::protobuf::StringValue optimization;
optimization.ParseFromString(join.advanced_extension().optimization().value());
JoinOptimizationInfo info;
if (optimization.value().contains("isBHJ="))
{
ReadBufferFromString in(optimization.value());
assertString("JoinParameters:", in);
assertString("isBHJ=", in);
readBoolText(info.is_broadcast, in);
assertChar('\n', in);
if (info.is_broadcast)
{
assertString("isNullAwareAntiJoin=", in);
readBoolText(info.is_null_aware_anti_join, in);
assertChar('\n', in);
assertString("buildHashTableId=", in);
readString(info.storage_join_key, in);
assertChar('\n', in);
}
}
else
{
ReadBufferFromString in(optimization.value());
assertString("JoinParameters:", in);
assertString("isSMJ=", in);
readBoolText(info.is_smj, in);
assertChar('\n', in);
if (info.is_smj)
{
assertString("isNullAwareAntiJoin=", in);
readBoolText(info.is_null_aware_anti_join, in);
assertChar('\n', in);
assertString("isExistenceJoin=", in);
readBoolText(info.is_existence_join, in);
assertChar('\n', in);
}
}
return info;
}

namespace local_engine
{
std::shared_ptr<DB::TableJoin> createDefaultTableJoin(substrait::JoinRel_JoinType join_type)
Expand Down Expand Up @@ -210,9 +261,7 @@ void JoinRelParser::renamePlanColumns(DB::QueryPlan & left, DB::QueryPlan & righ

DB::QueryPlanPtr JoinRelParser::parseJoin(const substrait::JoinRel & join, DB::QueryPlanPtr left, DB::QueryPlanPtr right)
{
google::protobuf::StringValue optimization_info;
optimization_info.ParseFromString(join.advanced_extension().optimization().value());
auto join_opt_info = JoinOptimizationInfo::parse(optimization_info.value());
auto join_opt_info = parseJoinOptimizationInfo(join);
auto storage_join = join_opt_info.is_broadcast ? BroadCastJoinBuilder::getJoin(join_opt_info.storage_join_key) : nullptr;
if (storage_join)
{
Expand Down

0 comments on commit da1143a

Please sign in to comment.