From 2335b1dcb17d842b58f4b1719187d75b49765fe3 Mon Sep 17 00:00:00 2001 From: Vasily Gerasimov Date: Sun, 25 Feb 2024 21:15:40 +0000 Subject: [PATCH 1/2] Test --- ydb/core/kqp/ut/service/kqp_qs_queries_ut.cpp | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ydb/core/kqp/ut/service/kqp_qs_queries_ut.cpp b/ydb/core/kqp/ut/service/kqp_qs_queries_ut.cpp index f7a2639a5968..2f4c45048261 100644 --- a/ydb/core/kqp/ut/service/kqp_qs_queries_ut.cpp +++ b/ydb/core/kqp/ut/service/kqp_qs_queries_ut.cpp @@ -662,6 +662,23 @@ Y_UNIT_TEST_SUITE(KqpQueryService) { } }; + auto checkRename = [&](bool expectSuccess, int nameSuffix, int nameSuffixTo) { + const TString sql = fmt::format(R"sql( + ALTER TABLE TestDdl_{name_suffix} RENAME TO TestDdl_{name_suffix_to} + )sql", + "name_suffix"_a = nameSuffix, + "name_suffix_to"_a = nameSuffixTo + ); + + auto result = db.ExecuteQuery(sql, TTxControl::NoTx()).ExtractValueSync(); + if (expectSuccess) { + UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString()); + } else { + UNIT_ASSERT_VALUES_UNEQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString()); + } + UNIT_ASSERT(result.GetResultSets().empty()); + }; + // usual create checkCreate(true, EEx::Empty, 0); checkUpsert(0); @@ -694,6 +711,15 @@ Y_UNIT_TEST_SUITE(KqpQueryService) { checkDrop(true, EEx::IfExists, 1); // real drop checkExists(false, 1); checkDrop(true, EEx::IfExists, 1); + + // rename + /* + checkCreate(true, EEx::Empty, 2); + checkRename(true, 2, 3); + checkRename(false, 2, 3); // already renamed, no such table + checkDrop(false, EEx::Empty, 2); // no such table + checkDrop(true, EEx::Empty, 3); + */ } Y_UNIT_TEST(DdlColumnTable) { From 964c81d86fd8a07fc6f54d463fbcb72b73c2fd36 Mon Sep 17 00:00:00 2001 From: Vasily Gerasimov Date: Mon, 26 Feb 2024 07:14:15 +0000 Subject: [PATCH 2/2] Fix build --- ydb/core/kqp/ut/service/kqp_qs_queries_ut.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ydb/core/kqp/ut/service/kqp_qs_queries_ut.cpp b/ydb/core/kqp/ut/service/kqp_qs_queries_ut.cpp index 2f4c45048261..4711257768d3 100644 --- a/ydb/core/kqp/ut/service/kqp_qs_queries_ut.cpp +++ b/ydb/core/kqp/ut/service/kqp_qs_queries_ut.cpp @@ -713,6 +713,7 @@ Y_UNIT_TEST_SUITE(KqpQueryService) { checkDrop(true, EEx::IfExists, 1); // rename + Y_UNUSED(checkRename); /* checkCreate(true, EEx::Empty, 2); checkRename(true, 2, 3);