Skip to content

Commit b2203a9

Browse files
Fixed CBO Level 1 and Level 2 (#12321)
Co-authored-by: Hor911 <hor911@ydb.tech>
1 parent d91df89 commit b2203a9

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

ydb/library/yql/dq/opt/dq_cbo_ut.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ void _DqOptimizeEquiJoinWithCosts(const std::function<IOptimizerNew*()>& optFact
227227
auto rel = std::make_shared<TRelOptimizerNode>(TString(label), stats);
228228
rels.push_back(rel);
229229
};
230-
auto res = DqOptimizeEquiJoinWithCosts(equiJoin, ctx, typeCtx, 1, *opt, providerCollect);
230+
auto res = DqOptimizeEquiJoinWithCosts(equiJoin, ctx, typeCtx, 2, *opt, providerCollect);
231231
UNIT_ASSERT(equiJoin.Ptr() != res.Ptr());
232232
UNIT_ASSERT(equiJoin.Ptr()->ChildrenSize() == res.Ptr()->ChildrenSize());
233233
UNIT_ASSERT(equiJoin.Maybe<TCoEquiJoin>());

ydb/library/yql/dq/opt/dq_opt_join_cost_based.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ TExprBase DqOptimizeEquiJoinWithCosts(
335335
int& equiJoinCounter,
336336
const TOptimizerHints& hints
337337
) {
338-
if (optLevel == 0) {
338+
if (optLevel <= 1) {
339339
return node;
340340
}
341341

ydb/library/yql/dq/opt/dq_opt_stat.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,10 @@ void InferStatisticsForAsList(const TExprNode::TPtr& input, TTypeAnnotationConte
558558
if (input->ChildrenSize() && input->Child(0)->IsCallable("AsStruct")) {
559559
nAttrs = input->Child(0)->ChildrenSize();
560560
}
561-
typeCtx->SetStats(input.Get(), std::make_shared<TOptimizerStatistics>(
562-
EStatisticsType::BaseTable, nRows, nAttrs, nRows*nAttrs, 0.0));
561+
auto outputStats = std::make_shared<TOptimizerStatistics>(
562+
EStatisticsType::BaseTable, nRows, nAttrs, nRows*nAttrs, 0.0);
563+
outputStats->StorageType = EStorageType::RowStorage;
564+
typeCtx->SetStats(input.Get(), outputStats);
563565
}
564566

565567
/***
@@ -580,6 +582,7 @@ bool InferStatisticsForListParam(const TExprNode::TPtr& input, TTypeAnnotationCo
580582
int nRows = 100;
581583
int nAttrs = maybeStructType.Cast().Ptr()->ChildrenSize();
582584
auto resStats = std::make_shared<TOptimizerStatistics>(EStatisticsType::BaseTable, nRows, nAttrs, nRows*nAttrs, 0.0);
585+
resStats->StorageType = EStorageType::RowStorage;
583586
typeCtx->SetStats(input.Get(), resStats);
584587
}
585588
}

ydb/library/yql/providers/dq/opt/logical_optimize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ class TDqsLogicalOptProposalTransformer : public TOptimizeTransformerBase {
291291
rels.push_back(rel);
292292
};
293293

294-
return DqOptimizeEquiJoinWithCosts(node, ctx, TypesCtx, 1, *opt, providerCollect);
294+
return DqOptimizeEquiJoinWithCosts(node, ctx, TypesCtx, 2, *opt, providerCollect);
295295
} else {
296296
return node;
297297
}

0 commit comments

Comments
 (0)