Skip to content

Commit

Permalink
[CBO] Added ANY ordering support
Browse files Browse the repository at this point in the history
  • Loading branch information
pashandor789 committed Sep 20, 2024
1 parent c2df8eb commit dc14ebd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ydb/library/yql/dq/opt/dq_opt_dphyp_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ template <typename TNodeSet> std::shared_ptr<TJoinOptimizerNodeInternal> TDPHypS
TJoinAlgoHints::TJoinAlgoHint* maybeJoinHint
) {
double bestCost = std::numeric_limits<double>::infinity();
EJoinAlgoType bestAlgo{};
EJoinAlgoType bestAlgo = EJoinAlgoType::Undefined;
bool bestJoinIsReversed = false;

for (auto joinAlgo : AllJoinAlgos) {
Expand Down Expand Up @@ -456,7 +456,7 @@ template <typename TNodeSet> std::shared_ptr<TJoinOptimizerNodeInternal> TDPHypS
}
}

Y_ENSURE(bestCost != std::numeric_limits<double>::infinity(), "No join was chosen!");
Y_ENSURE(bestAlgo != EJoinAlgoType::Undefined, "No join was chosen!");

if (bestJoinIsReversed) {
return MakeJoinInternal(right, left, reversedJoinConditions, rightJoinKeys, leftJoinKeys, joinKind, bestAlgo, rightAny, leftAny, ctx, maybeCardHint);
Expand Down
5 changes: 3 additions & 2 deletions ydb/library/yql/dq/opt/dq_opt_make_join_hypergraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ typename TJoinHypergraph<TNodeSet>::TEdge MakeHyperedge(


/* For CROSS Join and degenerate predicates (if subtree tables and joinCondition tables do not intersect) */
if (!Overlaps(TES, subtreeNodes[joinNode->LeftArg])) {
/* 'ANY' flag means leaving only one row from the join side. */
if (!Overlaps(TES, subtreeNodes[joinNode->LeftArg]) || joinNode->LeftAny) {
TES |= subtreeNodes[joinNode->LeftArg];
TES = ConvertConflictRulesIntoTES(TES, conflictRules);
}

if (!Overlaps(TES, subtreeNodes[joinNode->RightArg])) {
if (!Overlaps(TES, subtreeNodes[joinNode->RightArg]) || joinNode->RightAny) {
TES |= subtreeNodes[joinNode->RightArg];
TES = ConvertConflictRulesIntoTES(TES, conflictRules);
}
Expand Down

0 comments on commit dc14ebd

Please sign in to comment.