@@ -313,6 +313,21 @@ Y_UNIT_TEST_SUITE(TExternalTableTest) {
313
313
)" , {{NKikimrScheme::StatusPathDoesNotExist, " Check failed: path: '/MyRoot/ExternalDataSource1'" }});
314
314
}
315
315
316
+ std::vector<NKikimrSchemeOp::TColumnDescription> CheckExternalTable (TTestBasicRuntime& runtime, ui64 version, const TString& location) {
317
+ auto describeResult = DescribePath (runtime, " /MyRoot/ExternalTable" );
318
+ TestDescribeResult (describeResult, {NLs::PathExist});
319
+ UNIT_ASSERT (describeResult.GetPathDescription ().HasExternalTableDescription ());
320
+ const auto & externalTableDescription = describeResult.GetPathDescription ().GetExternalTableDescription ();
321
+ UNIT_ASSERT_VALUES_EQUAL (externalTableDescription.GetName (), " ExternalTable" );
322
+ UNIT_ASSERT_VALUES_EQUAL (externalTableDescription.GetDataSourcePath (), " /MyRoot/ExternalDataSource" );
323
+ UNIT_ASSERT_VALUES_EQUAL (externalTableDescription.GetLocation (), location);
324
+ UNIT_ASSERT_VALUES_EQUAL (externalTableDescription.GetSourceType (), " ObjectStorage" );
325
+ UNIT_ASSERT_VALUES_EQUAL (externalTableDescription.GetVersion (), version);
326
+
327
+ auto & columns = externalTableDescription.GetColumns ();
328
+ return {columns.begin (), columns.end ()};
329
+ }
330
+
316
331
Y_UNIT_TEST (ReplaceExternalTableIfNotExists) {
317
332
TTestBasicRuntime runtime;
318
333
TTestEnv env (runtime, TTestEnvOptions ().EnableReplaceIfExistsForExternalEntities (true ).RunFakeConfigDispatcher (true ));
@@ -331,20 +346,11 @@ Y_UNIT_TEST_SUITE(TExternalTableTest) {
331
346
env.TestWaitNotification (runtime, txId);
332
347
333
348
{
334
- auto describeResult = DescribePath (runtime, " /MyRoot/ExternalTable" );
335
- TestDescribeResult (describeResult, {NLs::PathExist});
336
- UNIT_ASSERT (describeResult.GetPathDescription ().HasExternalTableDescription ());
337
- const auto & externalTableDescription = describeResult.GetPathDescription ().GetExternalTableDescription ();
338
- UNIT_ASSERT_VALUES_EQUAL (externalTableDescription.GetName (), " ExternalTable" );
339
- UNIT_ASSERT_VALUES_EQUAL (externalTableDescription.GetDataSourcePath (), " /MyRoot/ExternalDataSource" );
340
- UNIT_ASSERT_VALUES_EQUAL (externalTableDescription.GetLocation (), " /" );
341
- UNIT_ASSERT_VALUES_EQUAL (externalTableDescription.GetSourceType (), " ObjectStorage" );
342
- UNIT_ASSERT_VALUES_EQUAL (externalTableDescription.GetVersion (), 1 );
343
- auto & columns = externalTableDescription.GetColumns ();
349
+ const auto & columns = CheckExternalTable (runtime, 1 , " /" );
344
350
UNIT_ASSERT_VALUES_EQUAL (columns.size (), 1 );
345
- UNIT_ASSERT_VALUES_EQUAL (columns. Get ( 0 ) .GetName (), " key" );
346
- UNIT_ASSERT_VALUES_EQUAL (columns. Get ( 0 ) .GetType (), " Uint64" );
347
- UNIT_ASSERT_VALUES_EQUAL (columns. Get ( 0 ) .GetNotNull (), false );
351
+ UNIT_ASSERT_VALUES_EQUAL (columns[ 0 ] .GetName (), " key" );
352
+ UNIT_ASSERT_VALUES_EQUAL (columns[ 0 ] .GetType (), " Uint64" );
353
+ UNIT_ASSERT_VALUES_EQUAL (columns[ 0 ] .GetNotNull (), false );
348
354
}
349
355
350
356
TestCreateExternalTable (runtime, ++txId, " /MyRoot" , R"(
@@ -359,23 +365,32 @@ Y_UNIT_TEST_SUITE(TExternalTableTest) {
359
365
env.TestWaitNotification (runtime, txId);
360
366
361
367
{
362
- auto describeResult = DescribePath (runtime, " /MyRoot/ExternalTable" );
363
- TestDescribeResult (describeResult, {NLs::PathExist});
364
- UNIT_ASSERT (describeResult.GetPathDescription ().HasExternalTableDescription ());
365
- const auto & externalTableDescription = describeResult.GetPathDescription ().GetExternalTableDescription ();
366
- UNIT_ASSERT_VALUES_EQUAL (externalTableDescription.GetName (), " ExternalTable" );
367
- UNIT_ASSERT_VALUES_EQUAL (externalTableDescription.GetDataSourcePath (), " /MyRoot/ExternalDataSource" );
368
- UNIT_ASSERT_VALUES_EQUAL (externalTableDescription.GetLocation (), " /new_location" );
369
- UNIT_ASSERT_VALUES_EQUAL (externalTableDescription.GetSourceType (), " ObjectStorage" );
370
- UNIT_ASSERT_VALUES_EQUAL (externalTableDescription.GetVersion (), 2 );
371
- auto & columns = externalTableDescription.GetColumns ();
368
+ const auto & columns = CheckExternalTable (runtime, 2 , " /new_location" );
372
369
UNIT_ASSERT_VALUES_EQUAL (columns.size (), 2 );
373
- UNIT_ASSERT_VALUES_EQUAL (columns.Get (0 ).GetName (), " key" );
374
- UNIT_ASSERT_VALUES_EQUAL (columns.Get (0 ).GetType (), " Uint64" );
375
- UNIT_ASSERT_VALUES_EQUAL (columns.Get (0 ).GetNotNull (), false );
376
- UNIT_ASSERT_VALUES_EQUAL (columns.Get (1 ).GetName (), " value" );
377
- UNIT_ASSERT_VALUES_EQUAL (columns.Get (1 ).GetType (), " Uint64" );
378
- UNIT_ASSERT_VALUES_EQUAL (columns.Get (1 ).GetNotNull (), false );
370
+ UNIT_ASSERT_VALUES_EQUAL (columns[0 ].GetName (), " key" );
371
+ UNIT_ASSERT_VALUES_EQUAL (columns[0 ].GetType (), " Uint64" );
372
+ UNIT_ASSERT_VALUES_EQUAL (columns[0 ].GetNotNull (), false );
373
+ UNIT_ASSERT_VALUES_EQUAL (columns[1 ].GetName (), " value" );
374
+ UNIT_ASSERT_VALUES_EQUAL (columns[1 ].GetType (), " Uint64" );
375
+ UNIT_ASSERT_VALUES_EQUAL (columns[1 ].GetNotNull (), false );
376
+ }
377
+
378
+ TestCreateExternalTable (runtime, ++txId, " /MyRoot" , R"(
379
+ Name: "ExternalTable"
380
+ SourceType: "General"
381
+ DataSourcePath: "/MyRoot/ExternalDataSource"
382
+ Location: "/other_location"
383
+ Columns { Name: "value" Type: "Uint64" }
384
+ ReplaceIfExists: true
385
+ )" , {NKikimrScheme::StatusAccepted});
386
+ env.TestWaitNotification (runtime, txId);
387
+
388
+ {
389
+ const auto & columns = CheckExternalTable (runtime, 3 , " /other_location" );
390
+ UNIT_ASSERT_VALUES_EQUAL (columns.size (), 1 );
391
+ UNIT_ASSERT_VALUES_EQUAL (columns[0 ].GetName (), " value" );
392
+ UNIT_ASSERT_VALUES_EQUAL (columns[0 ].GetType (), " Uint64" );
393
+ UNIT_ASSERT_VALUES_EQUAL (columns[0 ].GetNotNull (), false );
379
394
}
380
395
}
381
396
0 commit comments