Skip to content

Commit e9c2717

Browse files
authored
Avoid block aggregation in auto mode for YT (#8894)
1 parent c6d4d1b commit e9c2717

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

ydb/library/yql/core/yql_aggregate_expander.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace NYql {
99
class TAggregateExpander {
1010
public:
1111
TAggregateExpander(bool usePartitionsByKeys, const bool useFinalizeByKeys, const TExprNode::TPtr& node, TExprContext& ctx, TTypeAnnotationContext& typesCtx,
12-
bool forceCompact = false, bool compactForDistinct = false, bool usePhases = false, bool allowSpilling = false)
12+
bool forceCompact = false, bool compactForDistinct = false, bool usePhases = false, bool useBlocks = false)
1313
: Node(node)
1414
, Ctx(ctx)
1515
, TypesCtx(typesCtx)
@@ -25,7 +25,7 @@ class TAggregateExpander {
2525
, HaveSessionSetting(false)
2626
, OriginalRowType(nullptr)
2727
, RowType(nullptr)
28-
, UseBlocks(typesCtx.IsBlockEngineEnabled() && !allowSpilling)
28+
, UseBlocks(useBlocks)
2929
{
3030
PreMap = Ctx.Builder(node->Pos())
3131
.Lambda()
@@ -135,7 +135,7 @@ class TAggregateExpander {
135135
inline TExprNode::TPtr ExpandAggregatePeepholeImpl(const TExprNode::TPtr& node, TExprContext& ctx, TTypeAnnotationContext& typesCtx,
136136
const bool useFinalizeByKey, const bool useBlocks, const bool allowSpilling) {
137137
TAggregateExpander aggExpander(!useFinalizeByKey && !useBlocks, useFinalizeByKey, node, ctx, typesCtx,
138-
true, false, false, allowSpilling);
138+
true, false, false, typesCtx.IsBlockEngineEnabled() && !allowSpilling);
139139
return aggExpander.ExpandAggregate();
140140
}
141141

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ TExprBase DqRewriteAggregate(TExprBase node, TExprContext& ctx, TTypeAnnotationC
2323
return node;
2424
}
2525
TAggregateExpander aggExpander(!typesCtx.IsBlockEngineEnabled() && !useFinalizeByKey,
26-
useFinalizeByKey, node.Ptr(), ctx, typesCtx, false, compactForDistinct, usePhases, allowSpilling);
26+
useFinalizeByKey, node.Ptr(), ctx, typesCtx, false, compactForDistinct, usePhases,
27+
typesCtx.IsBlockEngineEnabled() && !allowSpilling);
2728
auto result = aggExpander.ExpandAggregate();
2829
YQL_ENSURE(result);
2930

ydb/library/yql/providers/yt/provider/yql_yt_logical_optimize.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ class TYtLogicalOptProposalTransformer : public TOptimizeTransformerBase {
354354

355355
auto usePhases = State_->Configuration->UseAggPhases.Get().GetOrElse(false);
356356
auto usePartitionsByKeys = State_->Configuration->UsePartitionsByKeysForFinalAgg.Get().GetOrElse(true);
357-
TAggregateExpander aggExpander(usePartitionsByKeys, false, node.Ptr(), ctx, *State_->Types, false, false, usePhases);
357+
TAggregateExpander aggExpander(usePartitionsByKeys, false, node.Ptr(), ctx, *State_->Types, false, false,
358+
usePhases, State_->Types->UseBlocks || State_->Types->BlockEngineMode == EBlockEngineMode::Force);
358359
return aggExpander.ExpandAggregate();
359360
}
360361

@@ -2518,7 +2519,8 @@ class TYtLogicalOptProposalTransformer : public TOptimizeTransformerBase {
25182519
return node;
25192520
}
25202521

2521-
return TAggregateExpander::CountAggregateRewrite(aggregate, ctx, State_->Types->IsBlockEngineEnabled());
2522+
return TAggregateExpander::CountAggregateRewrite(aggregate, ctx,
2523+
State_->Types->UseBlocks || State_->Types->BlockEngineMode == EBlockEngineMode::Force);
25222524
}
25232525

25242526
TMaybeNode<TExprBase> ZeroSampleToZeroLimit(TExprBase node, TExprContext& ctx) const {

0 commit comments

Comments
 (0)