@@ -8354,13 +8354,152 @@ Y_UNIT_TEST_SUITE(KqpOlapScheme) {
83548354 testHelper.BulkUpsert (testTable, batch);
83558355
83568356 auto alterQueryAdd = TStringBuilder () << " ALTER TABLE `" << testTable.GetName () << " ` DROP COLUMN int_column;" ;
8357- Cerr << alterQueryAdd << Endl;
83588357 auto alterAddResult = testHelper.GetSession ().ExecuteSchemeQuery (alterQueryAdd).GetValueSync ();
83598358 UNIT_ASSERT_VALUES_EQUAL_C (alterAddResult.GetStatus (), EStatus::SUCCESS, alterAddResult.GetIssues ().ToString ());
83608359
83618360 csController->EnableBackground (NYDBTest::ICSController::EBackground::Indexation);
83628361 csController->WaitIndexation (TDuration::Seconds (5 ));
83638362 }
8363+
8364+ void TestInsertAddInsertDrop (
8365+ bool autoIndexation, bool indexationAfterInsertAddColumn, bool indexationAfterInsertDropColumn, bool indexationInEnd) {
8366+ using namespace NArrow ;
8367+
8368+ auto csController = NYDBTest::TControllers::RegisterCSControllerGuard<NOlap::TWaitCompactionController>();
8369+ if (!autoIndexation) {
8370+ csController->DisableBackground (NYDBTest::ICSController::EBackground::Indexation);
8371+ }
8372+
8373+ TKikimrSettings runnerSettings;
8374+ runnerSettings.WithSampleTables = false ;
8375+ TTestHelper testHelper (runnerSettings);
8376+
8377+ TVector<TTestHelper::TColumnSchema> schema = {
8378+ TTestHelper::TColumnSchema ().SetName (" id" ).SetType (NScheme::NTypeIds::Uint64).SetNullable (false ),
8379+ TTestHelper::TColumnSchema ().SetName (" int_column" ).SetType (NScheme::NTypeIds::Int32).SetNullable (true )
8380+ };
8381+
8382+ TTestHelper::TColumnTable testTable;
8383+ testTable.SetName (" /Root/ColumnTableTest" ).SetPrimaryKey ({ " id" }).SetSchema (schema);
8384+ testHelper.CreateTable (testTable);
8385+
8386+ TVector<NConstruction::IArrayBuilder::TPtr> dataBuilders;
8387+ dataBuilders.push_back (
8388+ NConstruction::TSimpleArrayConstructor<NConstruction::TIntSeqFiller<arrow::UInt64Type>>::BuildNotNullable (" id" , false ));
8389+ dataBuilders.push_back (
8390+ std::make_shared<NConstruction::TSimpleArrayConstructor<NConstruction::TIntSeqFiller<arrow::Int32Type>>>(" int_column" ));
8391+ auto batch = NConstruction::TRecordBatchConstructor (dataBuilders).BuildBatch (100 );
8392+
8393+ for (ui32 i = 0 ; i < 5 ; i++) {
8394+ testHelper.BulkUpsert (testTable, batch);
8395+ auto alterQueryAdd = TStringBuilder () << " ALTER TABLE `" << testTable.GetName () << " ` ADD COLUMN column" << i << " Uint64;" ;
8396+ auto alterAddResult = testHelper.GetSession ().ExecuteSchemeQuery (alterQueryAdd).GetValueSync ();
8397+ UNIT_ASSERT_VALUES_EQUAL_C (alterAddResult.GetStatus (), EStatus::SUCCESS, alterAddResult.GetIssues ().ToString ());
8398+
8399+ if (!autoIndexation && indexationAfterInsertAddColumn) {
8400+ csController->EnableBackground (NYDBTest::ICSController::EBackground::Indexation);
8401+ csController->WaitIndexation (TDuration::Seconds (5 ));
8402+ csController->DisableBackground (NYDBTest::ICSController::EBackground::Indexation);
8403+ }
8404+
8405+ testHelper.BulkUpsert (testTable, batch);
8406+ auto alterQueryDrop = TStringBuilder () << " ALTER TABLE `" << testTable.GetName () << " ` DROP COLUMN column" << i << " ;" ;
8407+ auto alterDropResult = testHelper.GetSession ().ExecuteSchemeQuery (alterQueryDrop).GetValueSync ();
8408+ UNIT_ASSERT_VALUES_EQUAL_C (alterDropResult.GetStatus (), EStatus::SUCCESS, alterDropResult.GetIssues ().ToString ());
8409+
8410+ if (!autoIndexation && indexationAfterInsertDropColumn) {
8411+ csController->EnableBackground (NYDBTest::ICSController::EBackground::Indexation);
8412+ csController->WaitIndexation (TDuration::Seconds (5 ));
8413+ csController->DisableBackground (NYDBTest::ICSController::EBackground::Indexation);
8414+ }
8415+ }
8416+
8417+ if (!autoIndexation && indexationInEnd) {
8418+ csController->EnableBackground (NYDBTest::ICSController::EBackground::Indexation);
8419+ csController->WaitIndexation (TDuration::Seconds (5 ));
8420+ }
8421+ }
8422+
8423+ Y_UNIT_TEST (InsertAddInsertDrop) {
8424+ TestInsertAddInsertDrop (true , false , false , false );
8425+ for (i32 i = 0 ; i < 8 ; i++) {
8426+ TestInsertAddInsertDrop (false , i & 1 , i & 2 , i & 3 );
8427+ }
8428+ }
8429+
8430+ Y_UNIT_TEST (DropTableAfterInsert) {
8431+ using namespace NArrow ;
8432+
8433+ auto csController = NYDBTest::TControllers::RegisterCSControllerGuard<NOlap::TWaitCompactionController>();
8434+ csController->DisableBackground (NYDBTest::ICSController::EBackground::Indexation);
8435+
8436+ TKikimrSettings runnerSettings;
8437+ runnerSettings.WithSampleTables = false ;
8438+ TTestHelper testHelper (runnerSettings);
8439+
8440+ TVector<TTestHelper::TColumnSchema> schema = {
8441+ TTestHelper::TColumnSchema ().SetName (" id" ).SetType (NScheme::NTypeIds::Uint64).SetNullable (false ),
8442+ TTestHelper::TColumnSchema ().SetName (" int_column" ).SetType (NScheme::NTypeIds::Int32).SetNullable (true )
8443+ };
8444+
8445+ TTestHelper::TColumnTable testTable;
8446+ testTable.SetName (" /Root/ColumnTableTest" ).SetPrimaryKey ({ " id" }).SetSchema (schema);
8447+ testHelper.CreateTable (testTable);
8448+
8449+ TVector<NConstruction::IArrayBuilder::TPtr> dataBuilders;
8450+ dataBuilders.push_back (
8451+ NConstruction::TSimpleArrayConstructor<NConstruction::TIntSeqFiller<arrow::UInt64Type>>::BuildNotNullable (" id" , false ));
8452+ dataBuilders.push_back (
8453+ std::make_shared<NConstruction::TSimpleArrayConstructor<NConstruction::TIntSeqFiller<arrow::Int32Type>>>(" int_column" ));
8454+ auto batch = NConstruction::TRecordBatchConstructor (dataBuilders).BuildBatch (100 );
8455+
8456+ testHelper.BulkUpsert (testTable, batch);
8457+
8458+ auto alterQueryDrop = TStringBuilder () << " DROP TABLE `" << testTable.GetName () << " `;" ;
8459+ auto alterDropResult = testHelper.GetSession ().ExecuteSchemeQuery (alterQueryDrop).GetValueSync ();
8460+ UNIT_ASSERT_VALUES_EQUAL_C (alterDropResult.GetStatus (), EStatus::SUCCESS, alterDropResult.GetIssues ().ToString ());
8461+
8462+ csController->EnableBackground (NYDBTest::ICSController::EBackground::Indexation);
8463+ csController->WaitIndexation (TDuration::Seconds (5 ));
8464+ }
8465+
8466+ Y_UNIT_TEST (InsertDropAddColumn) {
8467+ using namespace NArrow ;
8468+
8469+ auto csController = NYDBTest::TControllers::RegisterCSControllerGuard<NOlap::TWaitCompactionController>();
8470+ csController->DisableBackground (NYDBTest::ICSController::EBackground::Indexation);
8471+
8472+ TKikimrSettings runnerSettings;
8473+ runnerSettings.WithSampleTables = false ;
8474+ TTestHelper testHelper (runnerSettings);
8475+
8476+ TVector<TTestHelper::TColumnSchema> schema = {
8477+ TTestHelper::TColumnSchema ().SetName (" id" ).SetType (NScheme::NTypeIds::Uint64).SetNullable (false ),
8478+ TTestHelper::TColumnSchema ().SetName (" int_column" ).SetType (NScheme::NTypeIds::Int32).SetNullable (true )
8479+ };
8480+
8481+ TTestHelper::TColumnTable testTable;
8482+ testTable.SetName (" /Root/ColumnTableTest" ).SetPrimaryKey ({ " id" }).SetSchema (schema);
8483+ testHelper.CreateTable (testTable);
8484+
8485+ TVector<NConstruction::IArrayBuilder::TPtr> dataBuilders;
8486+ dataBuilders.push_back (
8487+ NConstruction::TSimpleArrayConstructor<NConstruction::TIntSeqFiller<arrow::UInt64Type>>::BuildNotNullable (" id" , false ));
8488+ dataBuilders.push_back (
8489+ std::make_shared<NConstruction::TSimpleArrayConstructor<NConstruction::TIntSeqFiller<arrow::Int32Type>>>(" int_column" ));
8490+ auto batch = NConstruction::TRecordBatchConstructor (dataBuilders).BuildBatch (100 );
8491+
8492+ testHelper.BulkUpsert (testTable, batch);
8493+
8494+ auto alterQueryDrop = TStringBuilder () << " ALTER TABLE `" << testTable.GetName () << " ` DROP COLUMN int_column;" ;
8495+ auto alterDropResult = testHelper.GetSession ().ExecuteSchemeQuery (alterQueryDrop).GetValueSync ();
8496+
8497+ auto alterQueryAdd = TStringBuilder () << " ALTER TABLE `" << testTable.GetName () << " ` ADD COLUMN int_column Int32;" ;
8498+ auto alterAddResult = testHelper.GetSession ().ExecuteSchemeQuery (alterQueryAdd).GetValueSync ();
8499+
8500+ csController->EnableBackground (NYDBTest::ICSController::EBackground::Indexation);
8501+ csController->WaitIndexation (TDuration::Seconds (5 ));
8502+ }
83648503}
83658504
83668505Y_UNIT_TEST_SUITE (KqpOlapTypes) {
0 commit comments