Skip to content

Commit b0c5805

Browse files
iddqdexpnv1
andauthored
Check if tables exitst before init workloads (#21455)
Co-authored-by: Nikolay Perfilov <pnv1@yandex-team.ru>
1 parent 7832c40 commit b0c5805

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ydb/public/lib/ydb_cli/commands/ydb_workload.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,16 @@ int TWorkloadCommandInit::DoRun(NYdbWorkload::IWorkloadQueryGenerator& workloadG
501501
if (DryRun) {
502502
Cout << ddlQueries << Endl;
503503
} else {
504+
TVector<TString> existPaths;
505+
for (const auto& path: workloadGen.GetCleanPaths()) {
506+
const auto fullPath = config.Database + "/" + path.c_str();
507+
if (SchemeClient->DescribePath(fullPath).GetValueSync().IsSuccess()) {
508+
existPaths.emplace_back(path);
509+
}
510+
}
511+
if (existPaths) {
512+
throw yexception() << "Paths " << JoinSeq(", ", existPaths) << " already exist. Use 'ydb wokload " << Params.GetWorkloadName() << " clean' command or '--clear' option of 'init' command to cleanup tables.";
513+
}
504514
auto result = TableClient->RetryOperationSync([ddlQueries](NTable::TSession session) {
505515
return session.ExecuteSchemeQuery(ddlQueries.c_str()).GetValueSync();
506516
});

0 commit comments

Comments
 (0)