Skip to content

Commit 81c7860

Browse files
committed
[YQL-16903] Change default value for EmitAggApply and dq.EnableDqReplicate if BlockEngine is enabled
1 parent f024d8d commit 81c7860

File tree

8 files changed

+20
-9
lines changed

8 files changed

+20
-9
lines changed

ydb/library/yql/core/common_opt/yql_co_pgselect.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1858,7 +1858,8 @@ TExprNode::TPtr BuildAggregationTraits(TPositionHandle pos, bool onWindow, const
18581858
extractor = ctx.NewLambda(pos, std::move(arguments), std::move(aggFuncArgs));
18591859
}
18601860

1861-
if (optCtx.Types->PgEmitAggApply && !onWindow) {
1861+
const bool blockEngineEnabled = optCtx.Types->BlockEngineMode != EBlockEngineMode::Disable;
1862+
if (optCtx.Types->PgEmitAggApply.GetOrElse(blockEngineEnabled) && !onWindow) {
18621863
return ctx.Builder(pos)
18631864
.Callable("AggApply")
18641865
.Atom(0, TString("pg_") + func)

ydb/library/yql/core/yql_type_annotation.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ struct TTypeAnnotationContext: public TThrRefBase {
259259
ui32 FolderSubDirsLimit = 1000;
260260
bool UseBlocks = false;
261261
EBlockEngineMode BlockEngineMode = EBlockEngineMode::Disable;
262-
bool PgEmitAggApply = false;
262+
TMaybe<bool> PgEmitAggApply;
263263
IArrowResolver::TPtr ArrowResolver;
264264
ECostBasedOptimizerType CostBasedOptimizer = ECostBasedOptimizerType::Disable;
265265
bool MatchRecognize = false;

ydb/library/yql/providers/dq/common/yql_dq_settings.h

+5
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ struct TDqSettings {
209209
bool IsSpillingEnabled() const {
210210
return SpillingEngine.Get().GetOrElse(TDqSettings::TDefault::SpillingEngine) != ESpillingEngine::Disable;
211211
}
212+
213+
bool IsDqReplicateEnabled(const TTypeAnnotationContext& typesCtx) const {
214+
return EnableDqReplicate.Get().GetOrElse(
215+
typesCtx.BlockEngineMode != EBlockEngineMode::Disable || TDqSettings::TDefault::EnableDqReplicate);
216+
}
212217
};
213218

214219
struct TDqConfiguration: public TDqSettings, public NCommon::TSettingDispatcher {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class TDqsLogicalOptProposalTransformer : public TOptimizeTransformerBase {
101101
TMaybeNode<TExprBase> UnorderedOverDqReadWrap(TExprBase node, TExprContext& ctx, const TGetParents& getParents) const {
102102
const auto unordered = node.Cast<TCoUnorderedBase>();
103103
if (const auto maybeRead = unordered.Input().Maybe<TDqReadWrapBase>().Input()) {
104-
if (Config->EnableDqReplicate.Get().GetOrElse(TDqSettings::TDefault::EnableDqReplicate)) {
104+
if (Config->IsDqReplicateEnabled(TypesCtx)) {
105105
const TParentsMap* parentsMap = getParents();
106106
auto parentsIt = parentsMap->find(unordered.Input().Raw());
107107
YQL_ENSURE(parentsIt != parentsMap->cend());
@@ -127,7 +127,7 @@ class TDqsLogicalOptProposalTransformer : public TOptimizeTransformerBase {
127127
TMaybeNode<TExprBase> ExtractMembersOverDqReadWrap(TExprBase node, TExprContext& ctx, const TGetParents& getParents) {
128128
auto extract = node.Cast<TCoExtractMembers>();
129129
if (const auto maybeRead = extract.Input().Maybe<TDqReadWrap>().Input()) {
130-
if (Config->EnableDqReplicate.Get().GetOrElse(TDqSettings::TDefault::EnableDqReplicate)) {
130+
if (Config->IsDqReplicateEnabled(TypesCtx)) {
131131
const TParentsMap* parentsMap = getParents();
132132
auto parentsIt = parentsMap->find(extract.Input().Raw());
133133
YQL_ENSURE(parentsIt != parentsMap->cend());

ydb/library/yql/providers/dq/provider/yql_dq_datasink.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class TDqDataProviderSink: public TDataProviderBase {
3636
, PhysicalFinalizingTransformer([] () { return CreateDqsFinalizingOptTransformer(); })
3737
, TypeAnnotationTransformer([state] () {
3838
return CreateDqsDataSinkTypeAnnotationTransformer(
39-
state->TypeCtx, state->Settings->EnableDqReplicate.Get().GetOrElse(TDqSettings::TDefault::EnableDqReplicate));
39+
state->TypeCtx, state->Settings->IsDqReplicateEnabled(*state->TypeCtx));
4040
})
4141
, ConstraintsTransformer([] () { return CreateDqDataSinkConstraintTransformer(); })
4242
, RecaptureTransformer([state] () { return CreateDqsRecaptureTransformer(state); })

ydb/library/yql/sql/v1/aggregation.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ namespace {
2828
}
2929
return false;
3030
}
31+
32+
bool ShouldEmitAggApply(const TContext& ctx) {
33+
const bool blockEngineEnabled = ctx.BlockEngineEnable || ctx.BlockEngineForce;
34+
return ctx.EmitAggApply.GetOrElse(blockEngineEnabled);
35+
}
3136
}
3237

3338
static const THashSet<TString> AggApplyFuncs = {
@@ -58,7 +63,7 @@ class TAggregationFactory : public IAggregation {
5863

5964
protected:
6065
bool InitAggr(TContext& ctx, bool isFactory, ISource* src, TAstListNode& node, const TVector<TNodePtr>& exprs) override {
61-
if (!ctx.EmitAggApply) {
66+
if (!ShouldEmitAggApply(ctx)) {
6267
AggApplyName = "";
6368
}
6469

@@ -1349,7 +1354,7 @@ class TPGFactoryAggregation final : public TAggregationFactory {
13491354
Y_UNUSED(many);
13501355
Y_UNUSED(ctx);
13511356
Y_UNUSED(allowAggApply);
1352-
if (ctx.EmitAggApply && allowAggApply && AggMode != EAggregateMode::OverWindow) {
1357+
if (ShouldEmitAggApply(ctx) && allowAggApply && AggMode != EAggregateMode::OverWindow) {
13531358
return Y("AggApply",
13541359
Q("pg_" + to_lower(PgFunc)), Y("ListItemType", type), Lambda);
13551360
}

ydb/library/yql/sql/v1/context.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ THashMap<TStringBuf, TPragmaField> CTX_PRAGMA_FIELDS = {
5555
{"FlexibleTypes", &TContext::FlexibleTypes},
5656
{"AnsiCurrentRow", &TContext::AnsiCurrentRow},
5757
{"EmitStartsWith", &TContext::EmitStartsWith},
58-
{"EmitAggApply", &TContext::EmitAggApply},
5958
{"AnsiLike", &TContext::AnsiLike},
6059
{"UseBlocks", &TContext::UseBlocks},
6160
{"BlockEngineEnable", &TContext::BlockEngineEnable},
@@ -67,6 +66,7 @@ typedef TMaybe<bool> TContext::*TPragmaMaybeField;
6766
THashMap<TStringBuf, TPragmaMaybeField> CTX_PRAGMA_MAYBE_FIELDS = {
6867
{"AnsiRankForNullableKeys", &TContext::AnsiRankForNullableKeys},
6968
{"AnsiInForEmptyOrNullableItemsCollections", &TContext::AnsiInForEmptyOrNullableItemsCollections},
69+
{"EmitAggApply", &TContext::EmitAggApply},
7070
{"CompactGroupBy", &TContext::CompactGroupBy},
7171
};
7272

ydb/library/yql/sql/v1/context.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ namespace NSQLTranslationV1 {
305305
NYql::TWarningPolicy WarningPolicy;
306306
TString PqReadByRtmrCluster;
307307
bool EmitStartsWith = true;
308-
bool EmitAggApply = false;
308+
TMaybe<bool> EmitAggApply;
309309
bool UseBlocks = false;
310310
bool AnsiLike = false;
311311
bool FeatureR010 = false; //Row pattern recognition: FROM clause

0 commit comments

Comments
 (0)