@@ -22,7 +22,7 @@ struct TFixture : public TPqIoTestFixture {
22
22
}
23
23
24
24
void InitRdSource (
25
- NYql::NPq::NProto::TDqPqTopicSource& & settings,
25
+ const NYql::NPq::NProto::TDqPqTopicSource& settings,
26
26
i64 freeSpace = 1_MB)
27
27
{
28
28
CaSetup->Execute ([&](TFakeActor& actor) {
@@ -38,8 +38,9 @@ struct TFixture : public TPqIoTestFixture {
38
38
const THashMap<TString, TString> secureParams;
39
39
const THashMap<TString, TString> taskParams { {" pq" , serializedParams} };
40
40
41
+ NYql::NPq::NProto::TDqPqTopicSource copySettings = settings;
41
42
auto [dqSource, dqSourceAsActor] = CreateDqPqRdReadActor (
42
- std::move (settings ),
43
+ std::move (copySettings ),
43
44
0 ,
44
45
NYql::NDq::TCollectStatsLevel::None,
45
46
" query_1" ,
@@ -191,8 +192,8 @@ struct TFixture : public TPqIoTestFixture {
191
192
}
192
193
193
194
194
- void StartSession () {
195
- InitRdSource (BuildPqTopicSourceSettings ( " topicName " ) );
195
+ void StartSession (NYql::NPq::NProto::TDqPqTopicSource& settings ) {
196
+ InitRdSource (settings );
196
197
SourceRead<TString>(UVParser);
197
198
ExpectCoordinatorChangesSubscribe ();
198
199
@@ -204,13 +205,14 @@ struct TFixture : public TPqIoTestFixture {
204
205
MockAck (RowDispatcher1);
205
206
}
206
207
207
- void ProcessSomeJsons (ui64 offset, const std::vector<TString>& jsons, NActors::TActorId rowDispatcherId) {
208
+ void ProcessSomeJsons (ui64 offset, const std::vector<TString>& jsons, NActors::TActorId rowDispatcherId,
209
+ std::function<std::vector<TString>(const NUdf::TUnboxedValue&)> uvParser = UVParser) {
208
210
MockNewDataArrived (rowDispatcherId);
209
211
ExpectGetNextBatch (rowDispatcherId);
210
212
211
213
MockMessageBatch (offset, jsons, rowDispatcherId);
212
214
213
- auto result = SourceReadDataUntil<TString>(UVParser , jsons.size ());
215
+ auto result = SourceReadDataUntil<TString>(uvParser , jsons.size ());
214
216
AssertDataWithWatermarks (result, jsons, {});
215
217
}
216
218
@@ -219,6 +221,8 @@ struct TFixture : public TPqIoTestFixture {
219
221
const TString Json3 = " {\" dt\" :300,\" value\" :\" value3\" }" ;
220
222
const TString Json4 = " {\" dt\" :400,\" value\" :\" value4\" }" ;
221
223
224
+ NYql::NPq::NProto::TDqPqTopicSource Source1 = BuildPqTopicSourceSettings(" topicName" );
225
+
222
226
NActors::TActorId LocalRowDispatcherId;
223
227
NActors::TActorId Coordinator1Id;
224
228
NActors::TActorId Coordinator2Id;
@@ -228,12 +232,12 @@ struct TFixture : public TPqIoTestFixture {
228
232
229
233
Y_UNIT_TEST_SUITE (TDqPqRdReadActorTests) {
230
234
Y_UNIT_TEST_F (TestReadFromTopic, TFixture) {
231
- StartSession ();
235
+ StartSession (Source1 );
232
236
ProcessSomeJsons (0 , {Json1, Json2}, RowDispatcher1);
233
237
}
234
238
235
239
Y_UNIT_TEST_F (SessionError, TFixture) {
236
- StartSession ();
240
+ StartSession (Source1 );
237
241
238
242
TInstant deadline = Now () + TDuration::Seconds (5 );
239
243
auto future = CaSetup->AsyncInputPromises .FatalError .GetFuture ();
@@ -252,7 +256,7 @@ Y_UNIT_TEST_SUITE(TDqPqRdReadActorTests) {
252
256
}
253
257
254
258
Y_UNIT_TEST_F (ReadWithFreeSpace, TFixture) {
255
- StartSession ();
259
+ StartSession (Source1 );
256
260
257
261
MockNewDataArrived (RowDispatcher1);
258
262
ExpectGetNextBatch (RowDispatcher1);
@@ -275,15 +279,15 @@ Y_UNIT_TEST_SUITE(TDqPqRdReadActorTests) {
275
279
276
280
{
277
281
TFixture f;
278
- f.StartSession ();
282
+ f.StartSession (f. Source1 );
279
283
f.ProcessSomeJsons (0 , {f.Json1 , f.Json2 }, f.RowDispatcher1 ); // offsets: 0, 1
280
284
281
285
f.SaveSourceState (CreateCheckpoint (), state);
282
286
Cerr << " State saved" << Endl;
283
287
}
284
288
{
285
289
TFixture f;
286
- f.InitRdSource (BuildPqTopicSourceSettings ( " topicName " ) );
290
+ f.InitRdSource (f. Source1 );
287
291
f.SourceRead <TString>(UVParser);
288
292
f.LoadSource (state);
289
293
f.SourceRead <TString>(UVParser);
@@ -303,7 +307,7 @@ Y_UNIT_TEST_SUITE(TDqPqRdReadActorTests) {
303
307
}
304
308
{
305
309
TFixture f;
306
- f.InitRdSource (BuildPqTopicSourceSettings ( " topicName " ) );
310
+ f.InitRdSource (f. Source1 );
307
311
f.SourceRead <TString>(UVParser);
308
312
f.LoadSource (state);
309
313
f.SourceRead <TString>(UVParser);
@@ -321,7 +325,7 @@ Y_UNIT_TEST_SUITE(TDqPqRdReadActorTests) {
321
325
}
322
326
323
327
Y_UNIT_TEST_F (CoordinatorChanged, TFixture) {
324
- StartSession ();
328
+ StartSession (Source1 );
325
329
ProcessSomeJsons (0 , {Json1, Json2}, RowDispatcher1);
326
330
MockMessageBatch (2 , {Json3}, RowDispatcher1);
327
331
@@ -342,7 +346,7 @@ Y_UNIT_TEST_SUITE(TDqPqRdReadActorTests) {
342
346
}
343
347
344
348
Y_UNIT_TEST_F (RowDispatcherIsRestarted, TFixture) {
345
- StartSession ();
349
+ StartSession (Source1 );
346
350
ProcessSomeJsons (0 , {Json1, Json2}, RowDispatcher1);
347
351
MockDisconnected ();
348
352
MockConnected ();
@@ -361,5 +365,11 @@ Y_UNIT_TEST_SUITE(TDqPqRdReadActorTests) {
361
365
MockCoordinatorChanged (Coordinator2Id);
362
366
MockSessionError ();
363
367
}
364
- }
368
+
369
+ Y_UNIT_TEST_F (MetadataFields, TFixture) {
370
+ auto source = BuildPqTopicSourceSettings (" topicName" );
371
+ source.AddMetadataFields (" _yql_sys_create_time" );
372
+ StartSession (source);
373
+ ProcessSomeJsons (0 , {Json1}, RowDispatcher1, UVParserWithMetadatafields);
374
+ }
365
375
} // NYql::NDq
0 commit comments