Skip to content

Commit 08a390b

Browse files
gridnevvvitlll-phill-lll
authored andcommitted
add spilling nodes and pragma (#6769)
1 parent 6b5397c commit 08a390b

File tree

6 files changed

+29
-3
lines changed

6 files changed

+29
-3
lines changed

ydb/core/kqp/provider/yql_kikimr_exec.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,10 +815,11 @@ class TKiSourceCallableExecutionTransformer : public TAsyncCallbackTransformer<T
815815

816816
TVector<TExprBase> fakeReads;
817817
auto paramsType = NDq::CollectParameters(programLambda, ctx);
818+
NDq::TSpillingSettings spillingSettings{SessionCtx->Config().GetEnabledSpillingNodes()};
818819
lambda = NDq::BuildProgram(
819820
programLambda, *paramsType, compiler, SessionCtx->Query().QueryData->GetAllocState()->TypeEnv,
820821
*SessionCtx->Query().QueryData->GetAllocState()->HolderFactory.GetFunctionRegistry(),
821-
ctx, fakeReads, {});
822+
ctx, fakeReads, spillingSettings);
822823

823824
NKikimr::NMiniKQL::TProgramBuilder programBuilder(SessionCtx->Query().QueryData->GetAllocState()->TypeEnv,
824825
*SessionCtx->Query().QueryData->GetAllocState()->HolderFactory.GetFunctionRegistry());

ydb/core/kqp/provider/yql_kikimr_settings.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include <ydb/core/protos/config.pb.h>
44
#include <ydb/core/protos/table_service_config.pb.h>
55
#include <util/generic/size_literals.h>
6+
#include <util/string/split.h>
7+
#include <ydb/library/yql/providers/dq/common/yql_dq_settings.h>
68

79
namespace NYql {
810

@@ -73,6 +75,21 @@ TKikimrConfiguration::TKikimrConfiguration() {
7375

7476
REGISTER_SETTING(*this, OptUseFinalizeByKey);
7577
REGISTER_SETTING(*this, CostBasedOptimizationLevel);
78+
REGISTER_SETTING(*this, EnableSpillingNodes)
79+
.Parser([](const TString& v) {
80+
ui64 res = 0;
81+
TVector<TString> vec;
82+
StringSplitter(v).SplitBySet(",;| ").AddTo(&vec);
83+
for (auto& s: vec) {
84+
if (s.empty()) {
85+
throw yexception() << "Empty value item";
86+
}
87+
auto value = FromStringWithDefault<NYql::TDqSettings::EEnabledSpillingNodes>(
88+
s, NYql::TDqSettings::EEnabledSpillingNodes::None);
89+
res |= ui64(value);
90+
}
91+
return res;
92+
});
7693

7794
REGISTER_SETTING(*this, MaxDPccpDPTableSize);
7895

@@ -129,6 +146,10 @@ bool TKikimrSettings::HasOptUseFinalizeByKey() const {
129146
return GetOptionalFlagValue(OptUseFinalizeByKey.Get()) != EOptionalFlag::Disabled;
130147
}
131148

149+
ui64 TKikimrSettings::GetEnabledSpillingNodes() const {
150+
return EnableSpillingNodes.Get().GetOrElse(0);
151+
}
152+
132153

133154
EOptionalFlag TKikimrSettings::GetOptPredicateExtract() const {
134155
return GetOptionalFlagValue(OptEnablePredicateExtract.Get());

ydb/core/kqp/provider/yql_kikimr_settings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct TKikimrSettings {
5858
NCommon::TConfSetting<TString, false> OptCardinalityHints;
5959
NCommon::TConfSetting<TString, false> OptJoinAlgoHints;
6060
NCommon::TConfSetting<TString, false> OptJoinOrderHints;
61+
NCommon::TConfSetting<TString, false> OverrideStatistics;
6162

6263
/* Disable optimizer rules */
6364
NCommon::TConfSetting<bool, false> OptDisableTopSort;
@@ -89,6 +90,7 @@ struct TKikimrSettings {
8990
bool HasOptEnableOlapPushdown() const;
9091
bool HasOptEnableOlapProvideComputeSharding() const;
9192
bool HasOptUseFinalizeByKey() const;
93+
ui64 GetEnabledSpillingNodes() const;
9294

9395
EOptionalFlag GetOptPredicateExtract() const;
9496
EOptionalFlag GetUseLlvm() const;

ydb/core/kqp/query_compiler/kqp_query_compiler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,8 +777,9 @@ class TKqpQueryCompiler : public IKqpQueryCompiler {
777777
stageProto.SetIsEffectsStage(hasEffects || hasTxTableSink);
778778

779779
auto paramsType = CollectParameters(stage, ctx);
780+
NDq::TSpillingSettings spillingSettings{Config->GetEnabledSpillingNodes()};
780781
auto programBytecode = NDq::BuildProgram(stage.Program(), *paramsType, *KqlCompiler, TypeEnv, FuncRegistry,
781-
ctx, {}, {});
782+
ctx, {}, spillingSettings);
782783

783784
auto& programProto = *stageProto.MutableProgram();
784785
programProto.SetRuntimeVersion(NYql::NDqProto::ERuntimeVersion::RUNTIME_VERSION_YQL_1_0);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ TDqConfiguration::TDqConfiguration() {
110110
if (s.empty()) {
111111
throw yexception() << "Empty value item";
112112
}
113-
auto value = FromString<EEnabledSpillingNodes>(s);
113+
auto value = FromStringWithDefault<EEnabledSpillingNodes>(s, EEnabledSpillingNodes::None);
114114
res |= ui64(value);
115115
}
116116
return res;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct TDqSettings {
2929
};
3030

3131
enum class EEnabledSpillingNodes : ui64 {
32+
None = 0ULL /* None */,
3233
GraceJoin = 1ULL /* "GraceJoin" */,
3334
All = ~0ULL /* "All" */,
3435
};

0 commit comments

Comments
 (0)