@@ -32,7 +32,7 @@ NKikimrConfig::TAppConfig AppCfg() {
3232 return appCfg;
3333}
3434
35- NKikimrConfig::TAppConfig AppCfgLowComputeLimits (double reasonableTreshold) {
35+ NKikimrConfig::TAppConfig AppCfgLowComputeLimits (double reasonableTreshold, bool enableSpilling= true ) {
3636 NKikimrConfig::TAppConfig appCfg;
3737
3838 auto * rm = appCfg.MutableTableServiceConfig ()->MutableResourceManager ();
@@ -43,12 +43,32 @@ NKikimrConfig::TAppConfig AppCfgLowComputeLimits(double reasonableTreshold) {
4343
4444 auto * spilling = appCfg.MutableTableServiceConfig ()->MutableSpillingServiceConfig ()->MutableLocalFileConfig ();
4545
46- spilling->SetEnable (true );
46+ spilling->SetEnable (enableSpilling );
4747 spilling->SetRoot (" ./spilling/" );
4848
4949 return appCfg;
5050}
5151
52+ void FillTableWithData (NQuery::TQueryClient& db, ui64 numRows=300 ) {
53+ for (ui32 i = 0 ; i < numRows; ++i) {
54+ auto result = db.ExecuteQuery (Sprintf (R"(
55+ --!syntax_v1
56+ REPLACE INTO `/Root/KeyValue` (Key, Value) VALUES (%d, "%s")
57+ )" , i, TString (200000 + i, ' a' + (i % 26 )).c_str ()), NYdb::NQuery::TTxControl::BeginTx ().CommitTx ()).GetValueSync ();
58+ UNIT_ASSERT_C (result.IsSuccess (), result.GetIssues ().ToString ());
59+ }
60+ }
61+
62+ constexpr auto SimpleGraceJoinWithSpillingQuery = R"(
63+ --!syntax_v1
64+ PRAGMA ydb.EnableSpillingNodes="GraceJoin";
65+ PRAGMA ydb.CostBasedOptimizationLevel='0';
66+ PRAGMA ydb.HashJoinMode='graceandself';
67+ select t1.Key, t1.Value, t2.Key, t2.Value
68+ from `/Root/KeyValue` as t1 full join `/Root/KeyValue` as t2 on t1.Value = t2.Value
69+ order by t1.Value
70+ )" ;
71+
5272
5373} // anonymous namespace
5474
@@ -79,31 +99,15 @@ Y_UNIT_TEST_TWIN(SpillingInRuntimeNodes, EnabledSpilling) {
7999
80100 auto db = kikimr.GetQueryClient ();
81101
82- for (ui32 i = 0 ; i < 300 ; ++i) {
83- auto result = db.ExecuteQuery (Sprintf (R"(
84- --!syntax_v1
85- REPLACE INTO `/Root/KeyValue` (Key, Value) VALUES (%d, "%s")
86- )" , i, TString (200000 + i, ' a' + (i % 26 )).c_str ()), NYdb::NQuery::TTxControl::BeginTx ().CommitTx ()).GetValueSync ();
87- UNIT_ASSERT_C (result.IsSuccess (), result.GetIssues ().ToString ());
88- }
89-
90- auto query = R"(
91- --!syntax_v1
92- PRAGMA ydb.EnableSpillingNodes="GraceJoin";
93- PRAGMA ydb.CostBasedOptimizationLevel='0';
94- PRAGMA ydb.HashJoinMode='graceandself';
95- select t1.Key, t1.Value, t2.Key, t2.Value
96- from `/Root/KeyValue` as t1 full join `/Root/KeyValue` as t2 on t1.Value = t2.Value
97- order by t1.Value
98- )" ;
102+ FillTableWithData (db);
99103
100104 auto explainMode = NYdb::NQuery::TExecuteQuerySettings ().ExecMode (NYdb::NQuery::EExecMode::Explain);
101- auto planres = db.ExecuteQuery (query , NYdb::NQuery::TTxControl::NoTx (), explainMode).ExtractValueSync ();
105+ auto planres = db.ExecuteQuery (SimpleGraceJoinWithSpillingQuery , NYdb::NQuery::TTxControl::NoTx (), explainMode).ExtractValueSync ();
102106 UNIT_ASSERT_VALUES_EQUAL_C (planres.GetStatus (), EStatus::SUCCESS, planres.GetIssues ().ToString ());
103107
104108 Cerr << planres.GetStats ()->GetAst () << Endl;
105109
106- auto result = db.ExecuteQuery (query , NYdb::NQuery::TTxControl::BeginTx ().CommitTx (), NYdb::NQuery::TExecuteQuerySettings ()).ExtractValueSync ();
110+ auto result = db.ExecuteQuery (SimpleGraceJoinWithSpillingQuery , NYdb::NQuery::TTxControl::BeginTx ().CommitTx (), NYdb::NQuery::TExecuteQuerySettings ()).ExtractValueSync ();
107111 UNIT_ASSERT_VALUES_EQUAL_C (result.GetStatus (), EStatus::SUCCESS, result.GetIssues ().ToString ());
108112
109113 TKqpCounters counters (kikimr.GetTestServer ().GetRuntime ()->GetAppData ().Counters );
@@ -116,6 +120,24 @@ Y_UNIT_TEST_TWIN(SpillingInRuntimeNodes, EnabledSpilling) {
116120 }
117121}
118122
123+ Y_UNIT_TEST (HandleErrorsCorrectly) {
124+ Cerr << " cwd: " << NFs::CurrentWorkingDirectory () << Endl;
125+ TKikimrRunner kikimr (AppCfgLowComputeLimits (0.01 , false ));
126+
127+ auto db = kikimr.GetQueryClient ();
128+
129+ FillTableWithData (db);
130+
131+ auto explainMode = NYdb::NQuery::TExecuteQuerySettings ().ExecMode (NYdb::NQuery::EExecMode::Explain);
132+ auto planres = db.ExecuteQuery (SimpleGraceJoinWithSpillingQuery, NYdb::NQuery::TTxControl::NoTx (), explainMode).ExtractValueSync ();
133+ UNIT_ASSERT_VALUES_EQUAL_C (planres.GetStatus (), EStatus::SUCCESS, planres.GetIssues ().ToString ());
134+
135+ Cerr << planres.GetStats ()->GetAst () << Endl;
136+
137+ auto result = db.ExecuteQuery (SimpleGraceJoinWithSpillingQuery, NYdb::NQuery::TTxControl::BeginTx ().CommitTx (), NYdb::NQuery::TExecuteQuerySettings ()).ExtractValueSync ();
138+ UNIT_ASSERT_VALUES_EQUAL_C (result.GetStatus (), EStatus::INTERNAL_ERROR, result.GetIssues ().ToString ());
139+ }
140+
119141Y_UNIT_TEST (SelfJoinQueryService) {
120142 Cerr << " cwd: " << NFs::CurrentWorkingDirectory () << Endl;
121143
0 commit comments