diff --git a/ydb/library/yql/dq/opt/dq_opt_dphyp_solver.h b/ydb/library/yql/dq/opt/dq_opt_dphyp_solver.h index 67c9ee380840..142e97bab4f9 100644 --- a/ydb/library/yql/dq/opt/dq_opt_dphyp_solver.h +++ b/ydb/library/yql/dq/opt/dq_opt_dphyp_solver.h @@ -423,7 +423,7 @@ template std::shared_ptr TDPHypS TJoinAlgoHints::TJoinAlgoHint* maybeJoinHint ) { double bestCost = std::numeric_limits::infinity(); - EJoinAlgoType bestAlgo{}; + EJoinAlgoType bestAlgo = EJoinAlgoType::Undefined; bool bestJoinIsReversed = false; for (auto joinAlgo : AllJoinAlgos) { @@ -456,7 +456,7 @@ template std::shared_ptr TDPHypS } } - Y_ENSURE(bestCost != std::numeric_limits::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); diff --git a/ydb/library/yql/dq/opt/dq_opt_make_join_hypergraph.h b/ydb/library/yql/dq/opt/dq_opt_make_join_hypergraph.h index 6a0da29b578e..a1c779257838 100644 --- a/ydb/library/yql/dq/opt/dq_opt_make_join_hypergraph.h +++ b/ydb/library/yql/dq/opt/dq_opt_make_join_hypergraph.h @@ -44,12 +44,13 @@ typename TJoinHypergraph::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); }