Skip to content

Commit 5e30f9a

Browse files
committed
[CBO] Hints warning messages improvement
1 parent 4c98180 commit 5e30f9a

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

ydb/library/yql/core/cbo/cbo_optimizer_new.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ struct TCardinalityHints {
101101
struct TJoinAlgoHints {
102102
struct TJoinAlgoHint {
103103
TVector<TString> JoinLabels;
104-
EJoinAlgoType JoinHint;
104+
EJoinAlgoType Algo;
105105
TString StringRepr;
106106
bool Applied = false;
107107
};
108108

109109
TVector<TJoinAlgoHint> Hints;
110110

111-
void PushBack(TVector<TString> labels, EJoinAlgoType joinHint, TString stringRepr) {
112-
Hints.push_back({.JoinLabels = std::move(labels), .JoinHint = joinHint, .StringRepr = std::move(stringRepr)});
111+
void PushBack(TVector<TString> labels, EJoinAlgoType algo, TString stringRepr) {
112+
Hints.push_back({.JoinLabels = std::move(labels), .Algo = algo, .StringRepr = std::move(stringRepr)});
113113
}
114114
};
115115

ydb/library/yql/dq/opt/dq_opt_dphyp_solver.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)