@@ -32,26 +32,68 @@ NKikimrConfig::TAppConfig AppCfg() {
3232 return appCfg;
3333}
3434
35+ NKikimrConfig::TAppConfig AppCfgLowComputeLimits (ui64 reasonableTreshold) {
36+ NKikimrConfig::TAppConfig appCfg;
37+
38+ auto * rm = appCfg.MutableTableServiceConfig ()->MutableResourceManager ();
39+ rm->SetMkqlLightProgramMemoryLimit (100 );
40+ rm->SetMkqlHeavyProgramMemoryLimit (300 );
41+ rm->SetReasonableSpillingTreshold (reasonableTreshold);
42+ appCfg.MutableTableServiceConfig ()->SetEnableQueryServiceSpilling (true );
43+
44+ auto * spilling = appCfg.MutableTableServiceConfig ()->MutableSpillingServiceConfig ()->MutableLocalFileConfig ();
45+
46+ spilling->SetEnable (true );
47+ spilling->SetRoot (" ./spilling/" );
48+
49+ return appCfg;
50+ }
51+
52+
3553} // anonymous namespace
3654
3755Y_UNIT_TEST_SUITE (KqpScanSpilling) {
3856
39- Y_UNIT_TEST (SpillingPragmaParseError) {
57+ Y_UNIT_TEST_TWIN (SpillingInRuntimeNodes, EnabledSpilling) {
58+ ui64 reasonableTreshold = EnabledSpilling ? 100 : 200_MB;
4059 Cerr << " cwd: " << NFs::CurrentWorkingDirectory () << Endl;
41- TKikimrRunner kikimr (AppCfg ( ));
60+ TKikimrRunner kikimr (AppCfgLowComputeLimits (reasonableTreshold ));
4261
4362 auto db = kikimr.GetQueryClient ();
63+
64+ for (ui32 i = 0 ; i < 300 ; ++i) {
65+ auto result = db.ExecuteQuery (Sprintf (R"(
66+ --!syntax_v1
67+ REPLACE INTO `/Root/KeyValue` (Key, Value) VALUES (%d, "%s")
68+ )" , i, TString (200000 + i, ' a' + (i % 26 )).c_str ()), NYdb::NQuery::TTxControl::BeginTx ().CommitTx ()).GetValueSync ();
69+ UNIT_ASSERT_C (result.IsSuccess (), result.GetIssues ().ToString ());
70+ }
71+
4472 auto query = R"(
4573 --!syntax_v1
46- PRAGMA ydb.EnableSpillingNodes="GraceJoin1 ";
74+ PRAGMA ydb.EnableSpillingNodes="GraceJoin ";
4775 select t1.Key, t1.Value, t2.Key, t2.Value
4876 from `/Root/KeyValue` as t1 full join `/Root/KeyValue` as t2 on t1.Value = t2.Value
4977 order by t1.Value
5078 )" ;
5179
5280 auto explainMode = NYdb::NQuery::TExecuteQuerySettings ().ExecMode (NYdb::NQuery::EExecMode::Explain);
5381 auto planres = db.ExecuteQuery (query, NYdb::NQuery::TTxControl::NoTx (), explainMode).ExtractValueSync ();
54- UNIT_ASSERT_VALUES_EQUAL_C (planres.GetStatus (), EStatus::GENERIC_ERROR, planres.GetIssues ().ToString ());
82+ UNIT_ASSERT_VALUES_EQUAL_C (planres.GetStatus (), EStatus::SUCCESS, planres.GetIssues ().ToString ());
83+
84+ Cerr << planres.GetStats ()->GetAst () << Endl;
85+
86+ auto result = db.ExecuteQuery (query, NYdb::NQuery::TTxControl::BeginTx ().CommitTx (), NYdb::NQuery::TExecuteQuerySettings ()).ExtractValueSync ();
87+ UNIT_ASSERT_VALUES_EQUAL_C (result.GetStatus (), EStatus::SUCCESS, result.GetIssues ().ToString ());
88+
89+ TKqpCounters counters (kikimr.GetTestServer ().GetRuntime ()->GetAppData ().Counters );
90+ if (EnabledSpilling) {
91+ UNIT_ASSERT (counters.SpillingWriteBlobs ->Val () > 0 );
92+ UNIT_ASSERT (counters.SpillingReadBlobs ->Val () > 0 );
93+ } else {
94+ UNIT_ASSERT (counters.SpillingWriteBlobs ->Val () == 0 );
95+ UNIT_ASSERT (counters.SpillingReadBlobs ->Val () == 0 );
96+ }
5597}
5698
5799Y_UNIT_TEST (SelfJoinQueryService) {
0 commit comments