Skip to content

Commit

Permalink
Merge cd6f158 into 5a49f64
Browse files Browse the repository at this point in the history
  • Loading branch information
aavdonkin authored Sep 11, 2024
2 parents 5a49f64 + cd6f158 commit 58fdd0d
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ydb/core/kqp/ut/common/kqp_ut_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ struct TKikimrSettings: public TTestFeatureFlagsHolder<TKikimrSettings> {
exchangerSettings->SetStartDelayMs(10);
exchangerSettings->SetMaxDelayMs(10);
AppConfig.MutableColumnShardConfig()->SetDisabledOnSchemeShard(false);
NKikimrConfig::TFeatureFlags featureFlags;
featureFlags.SetEnableSparsedColumns(true);
SetFeatureFlags(featureFlags);
}

TKikimrSettings& SetAppConfig(const NKikimrConfig::TAppConfig& value) { AppConfig = value; return *this; }
Expand Down
3 changes: 3 additions & 0 deletions ydb/core/kqp/ut/olap/write_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ Y_UNIT_TEST_SUITE(KqpOlapWrite) {

Y_UNIT_TEST(DefaultValues) {
auto settings = TKikimrSettings().SetWithSampleTables(false);
NKikimrConfig::TFeatureFlags featureFlags;
featureFlags.SetEnableSparsedColumns(true);
settings.SetFeatureFlags(featureFlags);
TKikimrRunner kikimr(settings);
Tests::NCommon::TLoggerInit(kikimr).Initialize();
TTypedLocalHelper helper("Utf8", kikimr);
Expand Down
1 change: 1 addition & 0 deletions ydb/core/protos/feature_flags.proto
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,5 @@ message TFeatureFlags {
optional bool EnableTieringInColumnShard = 140 [default = false];
optional bool EnableMetadataObjectsOnServerless = 141 [default = true];
optional bool EnableOlapCompression = 142 [default = false];
optional bool EnableSparsedColumns = 143 [default = false];
}
12 changes: 12 additions & 0 deletions ydb/core/tx/schemeshard/olap/operations/alter/common/update.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <ydb/core/tx/schemeshard/olap/operations/alter/abstract/update.h>
#include <ydb/core/tx/schemeshard/olap/operations/alter/abstract/context.h>
#include <ydb/core/tx/schemeshard/olap/table/table.h>
#include <ydb/core/formats/arrow/accessor/common/const.h>

namespace NKikimr::NSchemeShard::NOlap::NAlter {

Expand Down Expand Up @@ -65,6 +66,17 @@ class TColumnTableUpdate: public ISSEntityUpdate {
return result;
}

bool CheckTargetSchema(const TOlapSchema& targetSchema) {
if (!AppData()->FeatureFlags.GetEnableSparsedColumns()) {
for (auto& [_, column]: targetSchema.GetColumns().GetColumns()) {
if (column.GetDefaultValue().GetValue() || (column.GetAccessorConstructor().GetClassName() == NKikimr::NArrow::NAccessor::TGlobalConst::SparsedDataAccessorName)) {
return false;
}
}
}
return true;
}

public:
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "update.h"
#include <ydb/core/tx/schemeshard/olap/operations/alter/abstract/converter.h>
#include <ydb/core/tx/schemeshard/olap/common/common.h>
#include <ydb/core/formats/arrow/accessor/common/const.h>

namespace NKikimr::NSchemeShard::NOlap::NAlter {

Expand Down Expand Up @@ -51,6 +52,9 @@ NKikimr::TConclusionStatus TStandaloneSchemaUpdate::DoInitializeImpl(const TUpda
}
}

if (!CheckTargetSchema(targetSchema)) {
return TConclusionStatus::Fail("schema update error: sparsed columns are disabled");
}
auto description = originalTable.GetTableInfoVerified().Description;
targetSchema.Serialize(*description.MutableSchema());
auto ttl = originalTable.GetTableTTLOptional() ? *originalTable.GetTableTTLOptional() : TOlapTTL();
Expand Down
12 changes: 12 additions & 0 deletions ydb/core/tx/schemeshard/olap/operations/alter_store.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <ydb/core/tx/schemeshard/schemeshard__operation_part.h>
#include <ydb/core/tx/schemeshard/schemeshard__operation_common.h>
#include <ydb/core/tx/schemeshard/schemeshard_impl.h>
#include <ydb/core/formats/arrow/accessor/common/const.h>

#include "checks.h"

Expand Down Expand Up @@ -525,6 +526,17 @@ class TAlterOlapStore: public TSubOperation {
return result;
}

if (!AppData()->FeatureFlags.GetEnableSparsedColumns()) {
for (auto& [_, preset]: alterData->SchemaPresets) {
for (auto& [_, column]: preset.GetColumns().GetColumns()) {
if (column.GetDefaultValue().GetValue() || (column.GetAccessorConstructor().GetClassName() == NKikimr::NArrow::NAccessor::TGlobalConst::SparsedDataAccessorName)) {
result->SetError(NKikimrScheme::StatusSchemeError,"schema update error: sparsed columns are disabled");
return result;
}
}
}
}

auto domainInfo = parentPath.DomainInfo();
const TSchemeLimits& limits = domainInfo->GetSchemeLimits();

Expand Down
11 changes: 11 additions & 0 deletions ydb/core/tx/schemeshard/ut_olap/ut_olap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,17 @@ Y_UNIT_TEST_SUITE(TOlap) {
}
}
)", {NKikimrScheme::StatusAccepted});

env.TestWaitNotification(runtime, txId);
TestAlterOlapStore(runtime, ++txId, "/MyRoot", R"(
Name: "OlapStore"
AlterSchemaPresets {
Name: "default"
AlterSchema {
AlterColumns { Name: "comment" DefaultValue: "10" }
}
}
)", {NKikimrScheme::StatusSchemeError});
}

Y_UNIT_TEST(AlterTtl) {
Expand Down
8 changes: 8 additions & 0 deletions ydb/core/tx/schemeshard/ut_ttl/ut_ttl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardColumnTableTTL) {
Columns { Name: "key" Type: "Uint64" NotNull: true }
Columns { Name: "modified_at" Type: "Timestamp" }
Columns { Name: "saved_at" Type: "Datetime" }
Columns { Name: "data" Type: "Utf8" }
KeyColumnNames: ["key"]
}
)");
Expand Down Expand Up @@ -1206,6 +1207,13 @@ Y_UNIT_TEST_SUITE(TSchemeShardColumnTableTTL) {
}
}
);
TestAlterColumnTable(runtime, ++txId, "/MyRoot", R"(
Name: "TTLEnabledTable"
AlterSchema {
AlterColumns {Name: "data" DefaultValue: "10"}
}
)", {NKikimrScheme::StatusSchemeError});
env.TestWaitNotification(runtime, txId);
}

Y_UNIT_TEST(AlterColumnTable_Negative) {
Expand Down

0 comments on commit 58fdd0d

Please sign in to comment.