Skip to content

Commit

Permalink
Merge f0c2341 into 1a998e8
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-gogov authored Sep 30, 2024
2 parents 1a998e8 + f0c2341 commit e37919a
Show file tree
Hide file tree
Showing 2 changed files with 100 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 @@ -21,6 +21,7 @@ ydb/core/kqp/ut/scheme [*/*]*
ydb/core/kqp/ut/scheme KqpOlapScheme.TenThousandColumns
ydb/core/kqp/ut/scheme KqpScheme.AlterAsyncReplication
ydb/core/kqp/ut/scheme KqpScheme.QueryWithAlter
ydb/core/kqp/ut/scheme KqpScheme.DropColumnAfterScan
ydb/core/kqp/ut/service [*/*]*
ydb/core/kqp/ut/service KqpQueryService.ExecuteQueryPgTableSelect
ydb/core/kqp/ut/service KqpQueryService.QueryOnClosedSession
Expand Down
99 changes: 99 additions & 0 deletions ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8326,6 +8326,105 @@ Y_UNIT_TEST_SUITE(KqpOlapScheme) {
testHelper.CreateTable(testTable, EStatus::SCHEME_ERROR);
}

Y_UNIT_TEST(DropColumnAfterScan) {
using namespace NArrow;

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

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

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

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

TVector<NConstruction::IArrayBuilder::TPtr> dataBuilders;
dataBuilders.push_back(
NConstruction::TSimpleArrayConstructor<NConstruction::TIntSeqFiller<arrow::UInt64Type>>::BuildNotNullable("id", false));
auto batch = NConstruction::TRecordBatchConstructor(dataBuilders).BuildBatch(100);
testHelper.BulkUpsert(testTable, batch);

{
auto alterQueryAdd = TStringBuilder()
<< "ALTER TABLE `" << testTable.GetName() << "` ADD COLUMN column" << schema.size() + 1 << " Uint64;";
Cerr << alterQueryAdd << Endl;
auto alterAddResult = testHelper.GetSession().ExecuteSchemeQuery(alterQueryAdd).GetValueSync();
UNIT_ASSERT_VALUES_EQUAL_C(alterAddResult.GetStatus(), EStatus::SUCCESS, alterAddResult.GetIssues().ToString());

testHelper.BulkUpsert(testTable, batch);
testHelper.ReadData("SELECT COUNT(*) FROM `/Root/ColumnTableTest`", "[[100u]]");

auto alterQueryDrop = TStringBuilder()
<< "ALTER TABLE `" << testTable.GetName() << "` DROP COLUMN column" << schema.size() + 1 << ";";
Cerr << alterQueryDrop << Endl;
auto alterDropResult = testHelper.GetSession().ExecuteSchemeQuery(alterQueryDrop).GetValueSync();
UNIT_ASSERT_VALUES_EQUAL_C(alterDropResult.GetStatus(), EStatus::SUCCESS, alterDropResult.GetIssues().ToString());
testHelper.ReadData("SELECT COUNT(*) FROM `/Root/ColumnTableTest`", "[[100u]]");
}

{
auto alterQueryAdd = TStringBuilder()
<< "ALTER TABLE `" << testTable.GetName() << "` ADD COLUMN column" << schema.size() + 1 << " Uint64;";
Cerr << alterQueryAdd << Endl;
auto alterAddResult = testHelper.GetSession().ExecuteSchemeQuery(alterQueryAdd).GetValueSync();
UNIT_ASSERT_VALUES_EQUAL_C(alterAddResult.GetStatus(), EStatus::SUCCESS, alterAddResult.GetIssues().ToString());

testHelper.BulkUpsert(testTable, batch);
testHelper.ReadData("SELECT COUNT(*) FROM `/Root/ColumnTableTest`", "[[100u]]");

auto alterQueryDrop = TStringBuilder()
<< "ALTER TABLE `" << testTable.GetName() << "` DROP COLUMN column" << schema.size() + 1 << ";";
Cerr << alterQueryDrop << Endl;
auto alterDropResult = testHelper.GetSession().ExecuteSchemeQuery(alterQueryDrop).GetValueSync();
UNIT_ASSERT_VALUES_EQUAL_C(alterDropResult.GetStatus(), EStatus::SUCCESS, alterDropResult.GetIssues().ToString());
testHelper.ReadData("SELECT COUNT(*) FROM `/Root/ColumnTableTest`", "[[100u]]");
}

{
auto alterQueryAdd = TStringBuilder()
<< "ALTER TABLE `" << testTable.GetName() << "` ADD COLUMN column" << schema.size() + 1 << " Uint64;";
Cerr << alterQueryAdd << Endl;
auto alterAddResult = testHelper.GetSession().ExecuteSchemeQuery(alterQueryAdd).GetValueSync();
UNIT_ASSERT_VALUES_EQUAL_C(alterAddResult.GetStatus(), EStatus::SUCCESS, alterAddResult.GetIssues().ToString());

testHelper.BulkUpsert(testTable, batch);
testHelper.ReadData("SELECT COUNT(*) FROM `/Root/ColumnTableTest`", "[[100u]]");

auto alterQueryDrop = TStringBuilder()
<< "ALTER TABLE `" << testTable.GetName() << "` DROP COLUMN column" << schema.size() + 1 << ";";
Cerr << alterQueryDrop << Endl;
auto alterDropResult = testHelper.GetSession().ExecuteSchemeQuery(alterQueryDrop).GetValueSync();
UNIT_ASSERT_VALUES_EQUAL_C(alterDropResult.GetStatus(), EStatus::SUCCESS, alterDropResult.GetIssues().ToString());
testHelper.ReadData("SELECT COUNT(*) FROM `/Root/ColumnTableTest`", "[[100u]]");
}

{
auto alterQueryAdd = TStringBuilder()
<< "ALTER TABLE `" << testTable.GetName() << "` ADD COLUMN column" << schema.size() + 1 << " Uint64;";
Cerr << alterQueryAdd << Endl;
auto alterAddResult = testHelper.GetSession().ExecuteSchemeQuery(alterQueryAdd).GetValueSync();
UNIT_ASSERT_VALUES_EQUAL_C(alterAddResult.GetStatus(), EStatus::SUCCESS, alterAddResult.GetIssues().ToString());

testHelper.BulkUpsert(testTable, batch);
testHelper.ReadData("SELECT COUNT(*) FROM `/Root/ColumnTableTest`", "[[100u]]");

auto alterQueryDrop = TStringBuilder()
<< "ALTER TABLE `" << testTable.GetName() << "` DROP COLUMN column" << schema.size() + 1 << ";";
Cerr << alterQueryDrop << Endl;
auto alterDropResult = testHelper.GetSession().ExecuteSchemeQuery(alterQueryDrop).GetValueSync();
UNIT_ASSERT_VALUES_EQUAL_C(alterDropResult.GetStatus(), EStatus::SUCCESS, alterDropResult.GetIssues().ToString());
testHelper.ReadData("SELECT COUNT(*) FROM `/Root/ColumnTableTest`", "[[100u]]");
}

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

Y_UNIT_TEST_SUITE(KqpOlapTypes) {
Expand Down

0 comments on commit e37919a

Please sign in to comment.