@@ -420,19 +420,20 @@ template <typename TNodeSet> std::shared_ptr<TJoinOptimizerNodeInternal> TDPHypS
420420 const TVector<TString>& rightJoinKeys,
421421 IProviderContext& ctx,
422422 TCardinalityHints::TCardinalityHint* maybeCardHint,
423- TJoinAlgoHints::TJoinAlgoHint* maybeJoinHint
423+ TJoinAlgoHints::TJoinAlgoHint* maybeJoinAlgoHint
424424) {
425+ if (maybeJoinAlgoHint) {
426+ maybeJoinAlgoHint->Applied = true ;
427+ return MakeJoinInternal (left, right, joinConditions, leftJoinKeys, rightJoinKeys, joinKind, maybeJoinAlgoHint->Algo , leftAny, rightAny, ctx, maybeCardHint);
428+ }
429+
425430 double bestCost = std::numeric_limits<double >::infinity ();
426431 EJoinAlgoType bestAlgo = EJoinAlgoType::Undefined;
427432 bool bestJoinIsReversed = false ;
428433
429434 for (auto joinAlgo : AllJoinAlgos) {
430435 if (ctx.IsJoinApplicable (left, right, joinConditions, leftJoinKeys, rightJoinKeys, joinAlgo, joinKind)){
431436 auto cost = ctx.ComputeJoinStats (*left->Stats , *right->Stats , leftJoinKeys, rightJoinKeys, joinAlgo, joinKind, maybeCardHint).Cost ;
432- if (maybeJoinHint && joinAlgo == maybeJoinHint->JoinHint ) {
433- cost = -1 ;
434- maybeJoinHint->Applied = true ;
435- }
436437 if (cost < bestCost) {
437438 bestCost = cost;
438439 bestAlgo = joinAlgo;
@@ -443,10 +444,6 @@ template <typename TNodeSet> std::shared_ptr<TJoinOptimizerNodeInternal> TDPHypS
443444 if (isCommutative) {
444445 if (ctx.IsJoinApplicable (right, left, reversedJoinConditions, rightJoinKeys, leftJoinKeys, joinAlgo, joinKind)){
445446 auto cost = ctx.ComputeJoinStats (*right->Stats , *left->Stats , rightJoinKeys, leftJoinKeys, joinAlgo, joinKind, maybeCardHint).Cost ;
446- if (maybeJoinHint && joinAlgo == maybeJoinHint->JoinHint ) {
447- cost = -1 ;
448- maybeJoinHint->Applied = true ;
449- }
450447 if (cost < bestCost) {
451448 bestCost = cost;
452449 bestAlgo = joinAlgo;
0 commit comments