@@ -32,10 +32,70 @@ NKikimrConfig::TAppConfig AppCfg() {
32
32
return appCfg;
33
33
}
34
34
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
+
35
53
} // anonymous namespace
36
54
37
55
Y_UNIT_TEST_SUITE (KqpScanSpilling) {
38
56
57
+ Y_UNIT_TEST_TWIN (SpillingInRuntimeNodes, EnabledSpilling) {
58
+ ui64 reasonableTreshold = EnabledSpilling ? 100 : 200_MB;
59
+ Cerr << " cwd: " << NFs::CurrentWorkingDirectory () << Endl;
60
+ TKikimrRunner kikimr (AppCfgLowComputeLimits (reasonableTreshold));
61
+
62
+ 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
+
72
+ auto query = R"(
73
+ --!syntax_v1
74
+ PRAGMA ydb.EnableSpillingNodes="GraceJoin";
75
+ select t1.Key, t1.Value, t2.Key, t2.Value
76
+ from `/Root/KeyValue` as t1 full join `/Root/KeyValue` as t2 on t1.Value = t2.Value
77
+ order by t1.Value
78
+ )" ;
79
+
80
+ auto explainMode = NYdb::NQuery::TExecuteQuerySettings ().ExecMode (NYdb::NQuery::EExecMode::Explain);
81
+ auto planres = db.ExecuteQuery (query, NYdb::NQuery::TTxControl::NoTx (), explainMode).ExtractValueSync ();
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
+ }
97
+ }
98
+
39
99
Y_UNIT_TEST (SelfJoinQueryService) {
40
100
Cerr << " cwd: " << NFs::CurrentWorkingDirectory () << Endl;
41
101
0 commit comments