Skip to content

Commit

Permalink
Merge 1c0a01e into f3a1a62
Browse files Browse the repository at this point in the history
  • Loading branch information
aavdonkin authored Sep 10, 2024
2 parents f3a1a62 + 1c0a01e commit 6ac7f19
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ydb/core/kqp/ut/olap/sparsed_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ Y_UNIT_TEST_SUITE(KqpOlapSparsed) {
const TVector<TString> FIELD_NAMES{"utf", "int", "uint", "float", "double"};
public:
TSparsedDataTest(const TString& storeName)
: Kikimr(Settings)
: Kikimr(GetKikimrSettings())
, CSController(NKikimr::NYDBTest::TControllers::RegisterCSControllerGuard<NKikimr::NYDBTest::NColumnShard::TController>())
, StoreName(storeName)
{
}

TKikimrSettings GetKikimrSettings() {
NKikimrConfig::TFeatureFlags featureFlags;
featureFlags.SetEnableSparsedColumns(true);
return TKikimrSettings().SetWithSampleTables(false).SetFeatureFlags(featureFlags);
}

ui32 GetCount() const {
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 @@ -158,4 +158,5 @@ message TFeatureFlags {
optional bool EnablePgSyntax = 139 [default = true];
optional bool EnableTieringInColumnShard = 140 [default = false];
optional bool EnableMetadataObjectsOnServerless = 141 [default = true];
optional bool EnableSparsedColumns = 142 [default = false];
}
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,14 @@ NKikimr::TConclusionStatus TStandaloneSchemaUpdate::DoInitializeImpl(const TUpda
}
}

if (!AppData()->FeatureFlags.GetEnableSparsedColumns()) {
for (auto& [_, column]: targetSchema.GetColumns().GetColumns()) {
if (column.GetDefaultValue().GetValue() || (column.GetAccessorConstructor().GetClassName() == NKikimr::NArrow::NAccessor::TGlobalConst::SparsedDataAccessorName)) {
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 @@ -508,6 +509,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 6ac7f19

Please sign in to comment.