|
2 | 2 | #include <ydb/core/kqp/ut/common/kqp_ut_common.h>
|
3 | 3 | #include <ydb/core/kqp/ut/common/columnshard.h>
|
4 | 4 | #include <ydb/core/tx/columnshard/hooks/testing/controller.h>
|
| 5 | +#include <ydb/core/tx/columnshard/test_helper/controllers.h> |
5 | 6 | #include <ydb/core/formats/arrow/arrow_helpers.h>
|
6 | 7 | #include <ydb/core/tx/tx_proxy/proxy.h>
|
7 | 8 | #include <ydb/public/sdk/cpp/client/draft/ydb_replication.h>
|
@@ -7848,6 +7849,65 @@ Y_UNIT_TEST_SUITE(KqpOlapScheme) {
|
7848 | 7849 | testHelper.ReadData("SELECT * FROM `/Root/ColumnTableTest` WHERE id=1", "[[1;#;[\"test_res_1\"]]]");
|
7849 | 7850 | }
|
7850 | 7851 |
|
| 7852 | + Y_UNIT_TEST(DropThenAddColumn) { |
| 7853 | + auto csController = NYDBTest::TControllers::RegisterCSControllerGuard<NOlap::TWaitCompactionController>(); |
| 7854 | + csController->DisableBackground(NYDBTest::ICSController::EBackground::Indexation); |
| 7855 | + csController->DisableBackground(NYDBTest::ICSController::EBackground::Compaction); |
| 7856 | + |
| 7857 | + TKikimrSettings runnerSettings; |
| 7858 | + runnerSettings.WithSampleTables = false; |
| 7859 | + TTestHelper testHelper(runnerSettings); |
| 7860 | + |
| 7861 | + TVector<TTestHelper::TColumnSchema> schema = { |
| 7862 | + TTestHelper::TColumnSchema().SetName("id").SetType(NScheme::NTypeIds::Int32).SetNullable(false), |
| 7863 | + TTestHelper::TColumnSchema().SetName("value").SetType(NScheme::NTypeIds::Utf8), |
| 7864 | + }; |
| 7865 | + |
| 7866 | + TTestHelper::TColumnTable testTable; |
| 7867 | + testTable.SetName("/Root/ColumnTableTest").SetPrimaryKey({ "id" }).SetSharding({ "id" }).SetSchema(schema); |
| 7868 | + testHelper.CreateTable(testTable); |
| 7869 | + |
| 7870 | + { |
| 7871 | + TTestHelper::TUpdatesBuilder tableInserter(testTable.GetArrowSchema(schema)); |
| 7872 | + tableInserter.AddRow().Add(1).Add("test_res_1"); |
| 7873 | + tableInserter.AddRow().Add(2).Add("test_res_2"); |
| 7874 | + testHelper.BulkUpsert(testTable, tableInserter); |
| 7875 | + } |
| 7876 | + |
| 7877 | + csController->EnableBackground(NYDBTest::ICSController::EBackground::Indexation); |
| 7878 | + csController->EnableBackground(NYDBTest::ICSController::EBackground::Compaction); |
| 7879 | + csController->WaitIndexation(TDuration::Seconds(5)); |
| 7880 | + csController->WaitCompactions(TDuration::Seconds(5)); |
| 7881 | + csController->DisableBackground(NYDBTest::ICSController::EBackground::Indexation); |
| 7882 | + csController->DisableBackground(NYDBTest::ICSController::EBackground::Compaction); |
| 7883 | + |
| 7884 | + { |
| 7885 | + auto alterQuery = TStringBuilder() << "ALTER TABLE `" << testTable.GetName() << "` DROP COLUMN value;"; |
| 7886 | + auto alterResult = testHelper.GetSession().ExecuteSchemeQuery(alterQuery).GetValueSync(); |
| 7887 | + UNIT_ASSERT_VALUES_EQUAL_C(alterResult.GetStatus(), EStatus::SUCCESS, alterResult.GetIssues().ToString()); |
| 7888 | + } |
| 7889 | + { |
| 7890 | + auto alterQuery = TStringBuilder() << "ALTER TABLE `" << testTable.GetName() << "` ADD COLUMN value Uint64;"; |
| 7891 | + auto alterResult = testHelper.GetSession().ExecuteSchemeQuery(alterQuery).GetValueSync(); |
| 7892 | + UNIT_ASSERT_VALUES_EQUAL_C(alterResult.GetStatus(), EStatus::SUCCESS, alterResult.GetIssues().ToString()); |
| 7893 | + } |
| 7894 | + schema.back().SetType(NScheme::NTypeIds::Uint64); |
| 7895 | + |
| 7896 | + { |
| 7897 | + TTestHelper::TUpdatesBuilder tableInserter(testTable.GetArrowSchema(schema)); |
| 7898 | + tableInserter.AddRow().Add(3).Add(42); |
| 7899 | + tableInserter.AddRow().Add(4).Add(43); |
| 7900 | + testHelper.BulkUpsert(testTable, tableInserter); |
| 7901 | + } |
| 7902 | + |
| 7903 | + csController->EnableBackground(NYDBTest::ICSController::EBackground::Indexation); |
| 7904 | + csController->EnableBackground(NYDBTest::ICSController::EBackground::Compaction); |
| 7905 | + csController->WaitIndexation(TDuration::Seconds(5)); |
| 7906 | + csController->WaitCompactions(TDuration::Seconds(5)); |
| 7907 | + |
| 7908 | + testHelper.ReadData("SELECT * FROM `/Root/ColumnTableTest`", "[[4;#;[\"test_res_1\"]]]"); |
| 7909 | + } |
| 7910 | + |
7851 | 7911 | Y_UNIT_TEST(DropTtlColumn) {
|
7852 | 7912 | TKikimrSettings runnerSettings;
|
7853 | 7913 | runnerSettings.WithSampleTables = false;
|
|
0 commit comments