Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sparsed columns are disabled by default and can be optionally enabled #9002

Merged
merged 5 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 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,7 @@ struct TKikimrSettings: public TTestFeatureFlagsHolder<TKikimrSettings> {
exchangerSettings->SetStartDelayMs(10);
exchangerSettings->SetMaxDelayMs(10);
AppConfig.MutableColumnShardConfig()->SetDisabledOnSchemeShard(false);
FeatureFlags.SetEnableSparsedColumns(true);
}

TKikimrSettings& SetAppConfig(const NKikimrConfig::TAppConfig& value) { AppConfig = value; return *this; }
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 @@ -160,4 +160,5 @@ message TFeatureFlags {
optional bool EnableMetadataObjectsOnServerless = 141 [default = true];
optional bool EnableOlapCompression = 142 [default = false];
optional bool EnableExternalDataSourcesOnServerless = 143 [default = true];
optional bool EnableSparsedColumns = 144 [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
Loading