@@ -32,7 +32,7 @@ NKikimrConfig::TAppConfig AppCfg() {
32
32
return appCfg;
33
33
}
34
34
35
- NKikimrConfig::TAppConfig AppCfgLowComputeLimits (double reasonableTreshold) {
35
+ NKikimrConfig::TAppConfig AppCfgLowComputeLimits (double reasonableTreshold, bool enableSpilling= true ) {
36
36
NKikimrConfig::TAppConfig appCfg;
37
37
38
38
auto * rm = appCfg.MutableTableServiceConfig ()->MutableResourceManager ();
@@ -43,12 +43,32 @@ NKikimrConfig::TAppConfig AppCfgLowComputeLimits(double reasonableTreshold) {
43
43
44
44
auto * spilling = appCfg.MutableTableServiceConfig ()->MutableSpillingServiceConfig ()->MutableLocalFileConfig ();
45
45
46
- spilling->SetEnable (true );
46
+ spilling->SetEnable (enableSpilling );
47
47
spilling->SetRoot (" ./spilling/" );
48
48
49
49
return appCfg;
50
50
}
51
51
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
+
52
72
53
73
} // anonymous namespace
54
74
@@ -79,31 +99,15 @@ Y_UNIT_TEST_TWIN(SpillingInRuntimeNodes, EnabledSpilling) {
79
99
80
100
auto db = kikimr.GetQueryClient ();
81
101
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);
99
103
100
104
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 ();
102
106
UNIT_ASSERT_VALUES_EQUAL_C (planres.GetStatus (), EStatus::SUCCESS, planres.GetIssues ().ToString ());
103
107
104
108
Cerr << planres.GetStats ()->GetAst () << Endl;
105
109
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 ();
107
111
UNIT_ASSERT_VALUES_EQUAL_C (result.GetStatus (), EStatus::SUCCESS, result.GetIssues ().ToString ());
108
112
109
113
TKqpCounters counters (kikimr.GetTestServer ().GetRuntime ()->GetAppData ().Counters );
@@ -116,6 +120,24 @@ Y_UNIT_TEST_TWIN(SpillingInRuntimeNodes, EnabledSpilling) {
116
120
}
117
121
}
118
122
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
+
119
141
Y_UNIT_TEST (SelfJoinQueryService) {
120
142
Cerr << " cwd: " << NFs::CurrentWorkingDirectory () << Endl;
121
143
0 commit comments