@@ -45,6 +45,11 @@ TTableDescription TableDescriptionFromProto(const Ydb::Table::CreateTableRequest
45
45
return TProtoAccessor::FromProto (proto);
46
46
}
47
47
48
+ TTableDescription TableDescriptionWithoutIndexesFromProto (Ydb::Table::CreateTableRequest proto) {
49
+ proto.clear_indexes ();
50
+ return TableDescriptionFromProto (proto);
51
+ }
52
+
48
53
Ydb::Scheme::ModifyPermissionsRequest ReadPermissions (const TString& fsPath) {
49
54
Ydb::Scheme::ModifyPermissionsRequest proto;
50
55
Y_ENSURE (google::protobuf::TextFormat::ParseFromString (TFileInput (fsPath).ReadAll (), &proto));
@@ -221,15 +226,25 @@ TRestoreResult TRestoreClient::RestoreTable(const TFsPath& fsPath, const TString
221
226
auto scheme = ReadTableScheme (fsPath.Child (SCHEME_FILE_NAME));
222
227
auto dumpedDesc = TableDescriptionFromProto (scheme);
223
228
229
+ if (dumpedDesc.GetAttributes ().contains (DOC_API_TABLE_VERSION_ATTR) && settings.SkipDocumentTables_ ) {
230
+ return Result<TRestoreResult>();
231
+ }
232
+
224
233
if (settings.DryRun_ ) {
225
234
return CheckSchema (dbPath, dumpedDesc);
226
235
}
227
236
228
- if (settings.RestoreData_ ) {
229
- auto woIndexes = scheme;
230
- woIndexes.clear_indexes ();
237
+ auto withoutIndexesDesc = TableDescriptionWithoutIndexesFromProto (scheme);
238
+ auto createResult = TableClient.RetryOperationSync ([&dbPath, &withoutIndexesDesc](TSession session) {
239
+ return session.CreateTable (dbPath, TTableDescription (withoutIndexesDesc),
240
+ TCreateTableSettings ().RequestType (DOC_API_REQUEST_TYPE)).GetValueSync ();
241
+ });
242
+ if (!createResult.IsSuccess ()) {
243
+ return Result<TRestoreResult>(dbPath, std::move (createResult));
244
+ }
231
245
232
- auto result = RestoreData (fsPath, dbPath, settings, TableDescriptionFromProto (woIndexes));
246
+ if (settings.RestoreData_ ) {
247
+ auto result = RestoreData (fsPath, dbPath, settings, withoutIndexesDesc);
233
248
if (!result.IsSuccess ()) {
234
249
return result;
235
250
}
@@ -303,18 +318,6 @@ struct TWriterWaiter {
303
318
};
304
319
305
320
TRestoreResult TRestoreClient::RestoreData (const TFsPath& fsPath, const TString& dbPath, const TRestoreSettings& settings, const TTableDescription& desc) {
306
- if (desc.GetAttributes ().contains (DOC_API_TABLE_VERSION_ATTR) && settings.SkipDocumentTables_ ) {
307
- return Result<TRestoreResult>();
308
- }
309
-
310
- auto createResult = TableClient.RetryOperationSync ([&dbPath, &desc](TSession session) {
311
- return session.CreateTable (dbPath, TTableDescription (desc),
312
- TCreateTableSettings ().RequestType (DOC_API_REQUEST_TYPE)).GetValueSync ();
313
- });
314
- if (!createResult.IsSuccess ()) {
315
- return Result<TRestoreResult>(dbPath, std::move (createResult));
316
- }
317
-
318
321
THolder<NPrivate::IDataAccumulator> accumulator;
319
322
THolder<NPrivate::IDataWriter> writer;
320
323
0 commit comments