Skip to content

Commit

Permalink
Address comment re enum pretty-printing, and add MergeJoin
Browse files Browse the repository at this point in the history
  • Loading branch information
alephonea committed May 21, 2024
1 parent 1dc5abf commit e277117
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 25 deletions.
6 changes: 5 additions & 1 deletion ydb/library/yql/core/cbo/cbo_optimizer_new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

#include <library/cpp/disjoint_sets/disjoint_sets.h>

const TString& ToString(NYql::EJoinKind);
const TString& ToString(NYql::EJoinAlgoType);

namespace NYql {

using namespace NYql::NDq;
Expand Down Expand Up @@ -89,7 +92,8 @@ void TJoinOptimizerNode::Print(std::stringstream& stream, int ntabs) {
stream << " ";
}

stream << "Join: (" << ConvertToJoinString(JoinType) << "," << ConvertToJoinAlgoString(JoinAlgo) << ") ";
stream << "Join: (" << ToString(JoinType) << "," << ToString(JoinAlgo) << ") ";

for (auto c : JoinConditions){
stream << c.first.RelName << "." << c.first.AttributeName
<< "=" << c.second.RelName << "."
Expand Down
2 changes: 2 additions & 0 deletions ydb/library/yql/core/cbo/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ SRCS(
cbo_optimizer_new.cpp
)

GENERATE_ENUM_SERIALIZATION(cbo_optimizer_new.h)

END()

RECURSE_FOR_TESTS(
Expand Down
20 changes: 0 additions & 20 deletions ydb/library/yql/core/yql_cost_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@

namespace NYql {

namespace {

THashMap<TString,EJoinAlgoType> JoinAlgoMap = {
{"Undefined",EJoinAlgoType::Undefined},
{"LookupJoin",EJoinAlgoType::LookupJoin},
{"MapJoin",EJoinAlgoType::MapJoin},
{"GraceJoin",EJoinAlgoType::GraceJoin},
{"StreamLookupJoin",EJoinAlgoType::StreamLookupJoin}};

} // namespace

bool NDq::operator < (const NDq::TJoinColumn& c1, const NDq::TJoinColumn& c2) {
if (c1.RelName < c2.RelName){
return true;
Expand All @@ -23,13 +12,4 @@ bool NDq::operator < (const NDq::TJoinColumn& c1, const NDq::TJoinColumn& c2) {
return false;
}

TString ConvertToJoinAlgoString(EJoinAlgoType joinAlgo) {
for (const auto& [k,v] : JoinAlgoMap) {
if (v == joinAlgo) {
return k;
}
}
Y_ENSURE(false, "Unknown join algo");
}

} // namespace NYql
7 changes: 3 additions & 4 deletions ydb/library/yql/core/yql_cost_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ enum class EJoinAlgoType {
LookupJoin,
MapJoin,
GraceJoin,
StreamLookupJoin //Right part can be updated during an operation. Used mainly for joining streams with lookup tables. Currently impplemented in Dq by LookupInputTransform
StreamLookupJoin, //Right part can be updated during an operation. Used mainly for joining streams with lookup tables. Currently impplemented in Dq by LookupInputTransform
MergeJoin // To be used in YT
};

//StreamLookupJoin is not a subject for CBO and not not included here
static constexpr auto AllJoinAlgos = { EJoinAlgoType::MapJoin, EJoinAlgoType::GraceJoin, EJoinAlgoType::LookupJoin };
static constexpr auto AllJoinAlgos = { EJoinAlgoType::MapJoin, EJoinAlgoType::GraceJoin, EJoinAlgoType::LookupJoin, EJoinAlgoType::MergeJoin };

namespace NDq {

Expand Down Expand Up @@ -57,6 +58,4 @@ bool operator < (const TJoinColumn& c1, const TJoinColumn& c2);

} // namespace NDq

TString ConvertToJoinAlgoString(EJoinAlgoType joinAlgo);

} // namespace NYql

0 comments on commit e277117

Please sign in to comment.