Skip to content
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
3 changes: 2 additions & 1 deletion ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5310,7 +5310,8 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::GENERIC_ERROR, result.GetIssues().ToString());
}

{ // no partition by
{ // nullable pk columns are disabled by default
kikimr.GetTestServer().GetRuntime()->GetAppData().ColumnShardConfig.SetAllowNullableColumnsInPK(false);
auto query = TStringBuilder() << R"(
--!syntax_v1
CREATE TABLE `)" << tableName << R"(` (
Expand Down
1 change: 1 addition & 0 deletions ydb/core/protos/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,7 @@ message TColumnShardConfig {
optional bool ColumnChunksV1Usage = 26 [default = true];
optional uint64 MemoryLimitScanPortion = 27 [default = 100000000];
optional string ReaderClassName = 28;
optional bool AllowNullableColumnsInPK = 29 [default = false];
}

message TSchemeShardConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ NKikimr::TConclusionStatus TStandaloneSchemaUpdate::DoInitializeImpl(const TUpda
return TConclusionStatus::Success();
}

}
}
2 changes: 1 addition & 1 deletion ydb/core/tx/schemeshard/olap/operations/create_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class TOlapTableConstructor : public TTableConstructorBase {
}

TOlapSchemaUpdate schemaDiff;
if (!schemaDiff.Parse(description.GetSchema(), errors)) {
if (!schemaDiff.Parse(description.GetSchema(), errors, AppData()->ColumnShardConfig.GetAllowNullableColumnsInPK())) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tx/schemeshard/olap/schema/update.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TOlapSchemaUpdate {
YDB_READONLY_DEF(TOlapColumnFamiliesUpdate, ColumnFamilies);

public:
bool Parse(const NKikimrSchemeOp::TColumnTableSchema& tableSchema, IErrorCollector& errors, bool allowNullKeys = false);
bool Parse(const NKikimrSchemeOp::TColumnTableSchema& tableSchema, IErrorCollector& errors, bool allowNullKeys);
bool Parse(const NKikimrSchemeOp::TAlterColumnTableSchema& alterRequest, IErrorCollector& errors);
};
}
2 changes: 1 addition & 1 deletion ydb/core/tx/schemeshard/olap/store/store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ bool TOlapStoreInfo::ParseFromRequest(const NKikimrSchemeOp::TColumnStoreDescrip
preset.SetProtoIndex(protoIndex++);

TOlapSchemaUpdate schemaDiff;
if (!schemaDiff.Parse(presetProto.GetSchema(), errors)) {
if (!schemaDiff.Parse(presetProto.GetSchema(), errors, AppData()->ColumnShardConfig.GetAllowNullableColumnsInPK())) {
return false;
}

Expand Down
77 changes: 76 additions & 1 deletion ydb/core/tx/schemeshard/ut_olap/ut_olap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,81 @@ Y_UNIT_TEST_SUITE(TOlap) {
TestLs(runtime, "/MyRoot/DirA/DirB/OlapStore", false, NLs::PathExist);
}

Y_UNIT_TEST(CreateTableWithNullableKeysNotAllowed) {
TTestBasicRuntime runtime;
TTestEnv env(runtime);
ui64 txId = 100;

auto& appData = runtime.GetAppData();
appData.ColumnShardConfig.SetAllowNullableColumnsInPK(false);

TestCreateOlapStore(runtime, ++txId, "/MyRoot", R"(
Name: "MyStore"
ColumnShardCount: 1
SchemaPresets {
Name: "default"
Schema {
Columns { Name: "timestamp" Type: "Timestamp" NotNull: true }
Columns { Name: "key1" Type: "Uint32" }
Columns { Name: "data" Type: "Utf8" }
KeyColumnNames: [ "timestamp", "key1" ]
}
}
)", {NKikimrScheme::StatusSchemeError});
env.TestWaitNotification(runtime, txId);
}

Y_UNIT_TEST(CreateTableWithNullableKeys) {
TTestBasicRuntime runtime;
TTestEnv env(runtime);
ui64 txId = 100;

auto& appData = runtime.GetAppData();
appData.ColumnShardConfig.SetAllowNullableColumnsInPK(true);

TestCreateOlapStore(runtime, ++txId, "/MyRoot", R"(
Name: "MyStore"
ColumnShardCount: 1
SchemaPresets {
Name: "default"
Schema {
Columns { Name: "timestamp" Type: "Timestamp" NotNull: true }
Columns { Name: "key1" Type: "Uint32" }
Columns { Name: "data" Type: "Utf8" }
KeyColumnNames: [ "timestamp", "key1" ]
}
}
)");
env.TestWaitNotification(runtime, txId);

TestLs(runtime, "/MyRoot/MyStore", false, NLs::PathExist);

TestMkDir(runtime, ++txId, "/MyRoot", "MyDir");
env.TestWaitNotification(runtime, txId);

TestLs(runtime, "/MyRoot/MyDir", false, NLs::PathExist);

TestCreateColumnTable(runtime, ++txId, "/MyRoot/MyDir", R"(
Name: "MyTable"
ColumnShardCount: 1
Schema {
Columns { Name: "timestamp" Type: "Timestamp" NotNull: true }
Columns { Name: "key1" Type: "Uint32" }
Columns { Name: "data" Type: "Utf8" }
KeyColumnNames: [ "timestamp", "key1" ]
}
)");
env.TestWaitNotification(runtime, txId);

TestLsPathId(runtime, 4, NLs::PathStringEqual("/MyRoot/MyDir/MyTable"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Что такое 4?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это pathId таблицы, они назначаются последовательно


TestDropColumnTable(runtime, ++txId, "/MyRoot/MyDir", "MyTable");
env.TestWaitNotification(runtime, txId);

TestLs(runtime, "/MyRoot/MyDir/MyTable", false, NLs::PathNotExist);
TestLsPathId(runtime, 4, NLs::PathStringEqual(""));
}

Y_UNIT_TEST(CreateTable) {
TTestBasicRuntime runtime;
TTestEnv env(runtime);
Expand Down Expand Up @@ -796,5 +871,5 @@ Y_UNIT_TEST_SUITE(TOlap) {
env.TestWaitNotification(runtime, txId);

TestLs(runtime, "/MyRoot/OlapStore", false, NLs::PathExist);
}
}
}
Loading