Skip to content

Commit 408814f

Browse files
authored
Merge 7399b60 into 68afe24
2 parents 68afe24 + 7399b60 commit 408814f

File tree

5 files changed

+50
-0
lines changed

5 files changed

+50
-0
lines changed

ydb/core/kqp/ut/common/columnshard.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ namespace NKqp {
2929
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());
3030
}
3131

32+
void TTestHelper::DropTable(const TString& tableName) {
33+
auto result = Session.DropTable(tableName).GetValueSync();
34+
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());
35+
}
36+
3237
void TTestHelper::BulkUpsert(const TColumnTable& table, TTestHelper::TUpdatesBuilder& updates, const Ydb::StatusIds_StatusCode& opStatus /*= Ydb::StatusIds::SUCCESS*/) {
3338
Y_UNUSED(opStatus);
3439
NKikimr::Tests::NCS::THelper helper(Kikimr.GetTestServer());

ydb/core/kqp/ut/common/columnshard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ namespace NKqp {
7171
TTestActorRuntime& GetRuntime();
7272
NYdb::NTable::TSession& GetSession();
7373
void CreateTable(const TColumnTableBase& table);
74+
void DropTable(const TString& tableName);
7475
void BulkUpsert(const TColumnTable& table, TTestHelper::TUpdatesBuilder& updates, const Ydb::StatusIds_StatusCode& opStatus = Ydb::StatusIds::SUCCESS);
7576
void BulkUpsert(const TColumnTable& table, std::shared_ptr<arrow::RecordBatch> batch, const Ydb::StatusIds_StatusCode& opStatus = Ydb::StatusIds::SUCCESS);
7677
void ReadData(const TString& query, const TString& expected, const NYdb::EStatus opStatus = NYdb::EStatus::SUCCESS);

ydb/core/kqp/ut/common/kqp_ut_common.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,18 @@ TVector<ui64> GetTableShards(Tests::TServer* server,
13061306
return shards;
13071307
}
13081308

1309+
TVector<ui64> GetColumnTableShards(Tests::TServer* server,
1310+
TActorId sender,
1311+
const TString &path)
1312+
{
1313+
TVector<ui64> shards;
1314+
auto lsResult = DescribeTable(server, sender, path);
1315+
for (auto &part : lsResult.GetPathDescription().GetColumnTableDescription().GetSharding().GetColumnShards())
1316+
shards.push_back(part);
1317+
1318+
return shards;
1319+
}
1320+
13091321
TVector<ui64> GetTableShards(Tests::TServer::TPtr server,
13101322
TActorId sender,
13111323
const TString &path) {

ydb/core/kqp/ut/common/kqp_ut_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ NKikimrScheme::TEvDescribeSchemeResult DescribeTable(Tests::TServer* server, TAc
325325
TVector<ui64> GetTableShards(Tests::TServer* server, TActorId sender, const TString &path);
326326

327327
TVector<ui64> GetTableShards(Tests::TServer::TPtr server, TActorId sender, const TString &path);
328+
TVector<ui64> GetColumnTableShards(Tests::TServer* server, TActorId sender, const TString &path);
328329

329330
void WaitForZeroSessions(const NKqp::TKqpCounters& counters);
330331

ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5129,6 +5129,37 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
51295129

51305130
Y_UNIT_TEST_SUITE(KqpOlapScheme) {
51315131

5132+
Y_UNIT_TEST(DropTable) {
5133+
TKikimrSettings runnerSettings;
5134+
runnerSettings.WithSampleTables = false;
5135+
TTestHelper testHelper(runnerSettings);
5136+
5137+
TVector<TTestHelper::TColumnSchema> schema = {
5138+
TTestHelper::TColumnSchema().SetName("id").SetType(NScheme::NTypeIds::Int32).SetNullable(false),
5139+
TTestHelper::TColumnSchema().SetName("id_second").SetType(NScheme::NTypeIds::Int32).SetNullable(false),
5140+
TTestHelper::TColumnSchema().SetName("level").SetType(NScheme::NTypeIds::Int32),
5141+
TTestHelper::TColumnSchema().SetName("created_at").SetType(NScheme::NTypeIds::Timestamp).SetNullable(false)
5142+
};
5143+
5144+
TTestHelper::TColumnTable testTable;
5145+
testTable
5146+
.SetName("/Root/ColumnTableTest")
5147+
.SetPrimaryKey({ "id", "id_second" })
5148+
.SetSharding({ "id" })
5149+
.SetMinPartitionsCount(16)
5150+
.SetSchema(schema);
5151+
testHelper.CreateTable(testTable);
5152+
auto sender = testHelper.GetRuntime().AllocateEdgeActor();
5153+
auto tabletIds = GetColumnTableShards(&testHelper.GetKikimr().GetTestServer(), sender, "/Root/ColumnTableTest");
5154+
for (auto tablet: tabletIds) {
5155+
UNIT_ASSERT_C(testHelper.GetKikimr().GetTestClient().TabletExistsInHive(&testHelper.GetRuntime(), tablet), ToString(tablet) + " not alive");
5156+
}
5157+
testHelper.DropTable("/Root/ColumnTableTest");
5158+
for (auto tablet: tabletIds) {
5159+
UNIT_ASSERT_C(!testHelper.GetKikimr().GetTestClient().TabletExistsInHive(&testHelper.GetRuntime(), tablet), ToString(tablet) + " is alive");
5160+
}
5161+
}
5162+
51325163
Y_UNIT_TEST(AddColumnLongPk) {
51335164
TKikimrSettings runnerSettings;
51345165
runnerSettings.WithSampleTables = false;

0 commit comments

Comments
 (0)