Skip to content

Commit

Permalink
Merge 18510fd into 4aa213a
Browse files Browse the repository at this point in the history
  • Loading branch information
swalrus1 authored Aug 29, 2024
2 parents 4aa213a + 18510fd commit b8557dd
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/config/muted_ya.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ydb/core/kqp/ut/query KqpLimits.QueryReplySize
ydb/core/kqp/ut/query KqpQuery.QueryTimeout
ydb/core/kqp/ut/scan KqpRequestContext.TraceIdInErrorMessage
ydb/core/kqp/ut/scheme [*/*]*
ydb/core/kqp/ut/scheme KqpOlapScheme.DropThenAddColumn
ydb/core/kqp/ut/scheme KqpOlapScheme.TenThousandColumns
ydb/core/kqp/ut/scheme KqpScheme.AlterAsyncReplication
ydb/core/kqp/ut/scheme KqpScheme.QueryWithAlter
Expand Down
60 changes: 60 additions & 0 deletions ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <ydb/core/kqp/ut/common/kqp_ut_common.h>
#include <ydb/core/kqp/ut/common/columnshard.h>
#include <ydb/core/tx/columnshard/hooks/testing/controller.h>
#include <ydb/core/tx/columnshard/test_helper/controllers.h>
#include <ydb/core/formats/arrow/arrow_helpers.h>
#include <ydb/core/tx/tx_proxy/proxy.h>
#include <ydb/public/sdk/cpp/client/draft/ydb_replication.h>
Expand Down Expand Up @@ -7848,6 +7849,65 @@ Y_UNIT_TEST_SUITE(KqpOlapScheme) {
testHelper.ReadData("SELECT * FROM `/Root/ColumnTableTest` WHERE id=1", "[[1;#;[\"test_res_1\"]]]");
}

Y_UNIT_TEST(DropThenAddColumn) {
auto csController = NYDBTest::TControllers::RegisterCSControllerGuard<NOlap::TWaitCompactionController>();
csController->DisableBackground(NYDBTest::ICSController::EBackground::Indexation);
csController->DisableBackground(NYDBTest::ICSController::EBackground::Compaction);

TKikimrSettings runnerSettings;
runnerSettings.WithSampleTables = false;
TTestHelper testHelper(runnerSettings);

TVector<TTestHelper::TColumnSchema> schema = {
TTestHelper::TColumnSchema().SetName("id").SetType(NScheme::NTypeIds::Int32).SetNullable(false),
TTestHelper::TColumnSchema().SetName("value").SetType(NScheme::NTypeIds::Utf8),
};

TTestHelper::TColumnTable testTable;
testTable.SetName("/Root/ColumnTableTest").SetPrimaryKey({ "id" }).SetSharding({ "id" }).SetSchema(schema);
testHelper.CreateTable(testTable);

{
TTestHelper::TUpdatesBuilder tableInserter(testTable.GetArrowSchema(schema));
tableInserter.AddRow().Add(1).Add("test_res_1");
tableInserter.AddRow().Add(2).Add("test_res_2");
testHelper.BulkUpsert(testTable, tableInserter);
}

csController->EnableBackground(NYDBTest::ICSController::EBackground::Indexation);
csController->EnableBackground(NYDBTest::ICSController::EBackground::Compaction);
csController->WaitIndexation(TDuration::Seconds(5));
csController->WaitCompactions(TDuration::Seconds(5));
csController->DisableBackground(NYDBTest::ICSController::EBackground::Indexation);
csController->DisableBackground(NYDBTest::ICSController::EBackground::Compaction);

{
auto alterQuery = TStringBuilder() << "ALTER TABLE `" << testTable.GetName() << "` DROP COLUMN value;";
auto alterResult = testHelper.GetSession().ExecuteSchemeQuery(alterQuery).GetValueSync();
UNIT_ASSERT_VALUES_EQUAL_C(alterResult.GetStatus(), EStatus::SUCCESS, alterResult.GetIssues().ToString());
}
{
auto alterQuery = TStringBuilder() << "ALTER TABLE `" << testTable.GetName() << "` ADD COLUMN value Uint64;";
auto alterResult = testHelper.GetSession().ExecuteSchemeQuery(alterQuery).GetValueSync();
UNIT_ASSERT_VALUES_EQUAL_C(alterResult.GetStatus(), EStatus::SUCCESS, alterResult.GetIssues().ToString());
}
schema.back().SetType(NScheme::NTypeIds::Uint64);

{
TTestHelper::TUpdatesBuilder tableInserter(testTable.GetArrowSchema(schema));
tableInserter.AddRow().Add(3).Add(42);
tableInserter.AddRow().Add(4).Add(43);
testHelper.BulkUpsert(testTable, tableInserter);
}

csController->EnableBackground(NYDBTest::ICSController::EBackground::Indexation);
csController->EnableBackground(NYDBTest::ICSController::EBackground::Compaction);
csController->WaitIndexation(TDuration::Seconds(5));
csController->WaitCompactions(TDuration::Seconds(5));

testHelper.ReadData("SELECT * FROM `/Root/ColumnTableTest`", "[[4;#;[\"test_res_1\"]]]");
}

Y_UNIT_TEST(DropTtlColumn) {
TKikimrSettings runnerSettings;
runnerSettings.WithSampleTables = false;
Expand Down

0 comments on commit b8557dd

Please sign in to comment.