Skip to content

Commit

Permalink
Merge 292de69 into 8d6b42b
Browse files Browse the repository at this point in the history
  • Loading branch information
swalrus1 authored Aug 29, 2024
2 parents 8d6b42b + 292de69 commit deace2c
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/config/muted_ya.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ydb/core/keyvalue/ut_trace TKeyValueTracingTest.*
ydb/core/kqp/provider/ut KikimrIcGateway.TestLoadBasicSecretValueFromExternalDataSourceMetadata
ydb/core/kqp/ut/olap KqpOlapBlobsSharing.*
ydb/core/kqp/ut/olap KqpOlapStatistics.StatsUsageWithTTL
ydb/core/kqp/ut/olap KqpOlapScheme.DropColumnAfterAdd
ydb/core/kqp/ut/pg KqpPg.CreateIndex
ydb/core/kqp/ut/query KqpLimits.QueryReplySize
ydb/core/kqp/ut/query KqpQuery.QueryTimeout
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
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ std::vector<TWritePortionInfoWithBlobsResult> TMerger::Execute(const std::shared
for (auto&& p : Batches) {
ui32 columnIdx = 0;
for (auto&& i : p->GetSchema()->GetFields()) {
const std::optional<ui32> columnId = resultFiltered->GetIndexInfo().GetColumnIdOptional(i->name());
const std::optional<ui32> columnId = resultFiltered->GetColumnIdOptional(i->name());
if (columnId) {
auto it = columnsData.find(*columnId);
if (it == columnsData.end()) {
Expand Down

0 comments on commit deace2c

Please sign in to comment.