Skip to content

Commit ca964ba

Browse files
authored
Sparsed columns are disabled by default and can be optionally enabled (#9002)
1 parent 9ad031e commit ca964ba

File tree

7 files changed

+49
-0
lines changed

7 files changed

+49
-0
lines changed

ydb/core/kqp/ut/common/kqp_ut_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ struct TKikimrSettings: public TTestFeatureFlagsHolder<TKikimrSettings> {
9797
exchangerSettings->SetStartDelayMs(10);
9898
exchangerSettings->SetMaxDelayMs(10);
9999
AppConfig.MutableColumnShardConfig()->SetDisabledOnSchemeShard(false);
100+
FeatureFlags.SetEnableSparsedColumns(true);
100101
}
101102

102103
TKikimrSettings& SetAppConfig(const NKikimrConfig::TAppConfig& value) { AppConfig = value; return *this; }

ydb/core/protos/feature_flags.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,5 @@ message TFeatureFlags {
160160
optional bool EnableMetadataObjectsOnServerless = 141 [default = true];
161161
optional bool EnableOlapCompression = 142 [default = false];
162162
optional bool EnableExternalDataSourcesOnServerless = 143 [default = true];
163+
optional bool EnableSparsedColumns = 144 [default = false];
163164
}

ydb/core/tx/schemeshard/olap/operations/alter/common/update.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <ydb/core/tx/schemeshard/olap/operations/alter/abstract/update.h>
33
#include <ydb/core/tx/schemeshard/olap/operations/alter/abstract/context.h>
44
#include <ydb/core/tx/schemeshard/olap/table/table.h>
5+
#include <ydb/core/formats/arrow/accessor/common/const.h>
56

67
namespace NKikimr::NSchemeShard::NOlap::NAlter {
78

@@ -65,6 +66,17 @@ class TColumnTableUpdate: public ISSEntityUpdate {
6566
return result;
6667
}
6768

69+
bool CheckTargetSchema(const TOlapSchema& targetSchema) {
70+
if (!AppData()->FeatureFlags.GetEnableSparsedColumns()) {
71+
for (auto& [_, column]: targetSchema.GetColumns().GetColumns()) {
72+
if (column.GetDefaultValue().GetValue() || (column.GetAccessorConstructor().GetClassName() == NKikimr::NArrow::NAccessor::TGlobalConst::SparsedDataAccessorName)) {
73+
return false;
74+
}
75+
}
76+
}
77+
return true;
78+
}
79+
6880
public:
6981
};
7082

ydb/core/tx/schemeshard/olap/operations/alter/standalone/update.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "update.h"
22
#include <ydb/core/tx/schemeshard/olap/operations/alter/abstract/converter.h>
33
#include <ydb/core/tx/schemeshard/olap/common/common.h>
4+
#include <ydb/core/formats/arrow/accessor/common/const.h>
45

56
namespace NKikimr::NSchemeShard::NOlap::NAlter {
67

@@ -51,6 +52,9 @@ NKikimr::TConclusionStatus TStandaloneSchemaUpdate::DoInitializeImpl(const TUpda
5152
}
5253
}
5354

55+
if (!CheckTargetSchema(targetSchema)) {
56+
return TConclusionStatus::Fail("schema update error: sparsed columns are disabled");
57+
}
5458
auto description = originalTable.GetTableInfoVerified().Description;
5559
targetSchema.Serialize(*description.MutableSchema());
5660
auto ttl = originalTable.GetTableTTLOptional() ? *originalTable.GetTableTTLOptional() : TOlapTTL();

ydb/core/tx/schemeshard/olap/operations/alter_store.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <ydb/core/tx/schemeshard/schemeshard__operation_part.h>
22
#include <ydb/core/tx/schemeshard/schemeshard__operation_common.h>
33
#include <ydb/core/tx/schemeshard/schemeshard_impl.h>
4+
#include <ydb/core/formats/arrow/accessor/common/const.h>
45

56
#include "checks.h"
67

@@ -525,6 +526,17 @@ class TAlterOlapStore: public TSubOperation {
525526
return result;
526527
}
527528

529+
if (!AppData()->FeatureFlags.GetEnableSparsedColumns()) {
530+
for (auto& [_, preset]: alterData->SchemaPresets) {
531+
for (auto& [_, column]: preset.GetColumns().GetColumns()) {
532+
if (column.GetDefaultValue().GetValue() || (column.GetAccessorConstructor().GetClassName() == NKikimr::NArrow::NAccessor::TGlobalConst::SparsedDataAccessorName)) {
533+
result->SetError(NKikimrScheme::StatusSchemeError,"schema update error: sparsed columns are disabled");
534+
return result;
535+
}
536+
}
537+
}
538+
}
539+
528540
auto domainInfo = parentPath.DomainInfo();
529541
const TSchemeLimits& limits = domainInfo->GetSchemeLimits();
530542

ydb/core/tx/schemeshard/ut_olap/ut_olap.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,17 @@ Y_UNIT_TEST_SUITE(TOlap) {
557557
}
558558
}
559559
)", {NKikimrScheme::StatusAccepted});
560+
561+
env.TestWaitNotification(runtime, txId);
562+
TestAlterOlapStore(runtime, ++txId, "/MyRoot", R"(
563+
Name: "OlapStore"
564+
AlterSchemaPresets {
565+
Name: "default"
566+
AlterSchema {
567+
AlterColumns { Name: "comment" DefaultValue: "10" }
568+
}
569+
}
570+
)", {NKikimrScheme::StatusSchemeError});
560571
}
561572

562573
Y_UNIT_TEST(AlterTtl) {

ydb/core/tx/schemeshard/ut_ttl/ut_ttl.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardColumnTableTTL) {
11501150
Columns { Name: "key" Type: "Uint64" NotNull: true }
11511151
Columns { Name: "modified_at" Type: "Timestamp" }
11521152
Columns { Name: "saved_at" Type: "Datetime" }
1153+
Columns { Name: "data" Type: "Utf8" }
11531154
KeyColumnNames: ["key"]
11541155
}
11551156
)");
@@ -1206,6 +1207,13 @@ Y_UNIT_TEST_SUITE(TSchemeShardColumnTableTTL) {
12061207
}
12071208
}
12081209
);
1210+
TestAlterColumnTable(runtime, ++txId, "/MyRoot", R"(
1211+
Name: "TTLEnabledTable"
1212+
AlterSchema {
1213+
AlterColumns {Name: "data" DefaultValue: "10"}
1214+
}
1215+
)", {NKikimrScheme::StatusSchemeError});
1216+
env.TestWaitNotification(runtime, txId);
12091217
}
12101218

12111219
Y_UNIT_TEST(AlterColumnTable_Negative) {

0 commit comments

Comments
 (0)