Skip to content

Commit 70cc091

Browse files
authored
Merge 2e7bcd3 into ffa5093
2 parents ffa5093 + 2e7bcd3 commit 70cc091

File tree

7 files changed

+83
-6
lines changed

7 files changed

+83
-6
lines changed

ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5310,7 +5310,8 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
53105310
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::GENERIC_ERROR, result.GetIssues().ToString());
53115311
}
53125312

5313-
{ // no partition by
5313+
{ // nullable pk columns are disabled by default
5314+
kikimr.GetTestServer().GetRuntime()->GetAppData().ColumnShardConfig.SetAllowNullableColumnsInPK(false);
53145315
auto query = TStringBuilder() << R"(
53155316
--!syntax_v1
53165317
CREATE TABLE `)" << tableName << R"(` (

ydb/core/protos/config.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,6 +1703,7 @@ message TColumnShardConfig {
17031703
optional bool ColumnChunksV1Usage = 26 [default = true];
17041704
optional uint64 MemoryLimitScanPortion = 27 [default = 100000000];
17051705
optional string ReaderClassName = 28;
1706+
optional bool AllowNullableColumnsInPK = 29 [default = false];
17061707
}
17071708

17081709
message TSchemeShardConfig {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ NKikimr::TConclusionStatus TStandaloneSchemaUpdate::DoInitializeImpl(const TUpda
7676
return TConclusionStatus::Success();
7777
}
7878

79-
}
79+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ class TOlapTableConstructor : public TTableConstructorBase {
193193
}
194194

195195
TOlapSchemaUpdate schemaDiff;
196-
if (!schemaDiff.Parse(description.GetSchema(), errors)) {
196+
if (!schemaDiff.Parse(description.GetSchema(), errors, AppData()->ColumnShardConfig.GetAllowNullableColumnsInPK())) {
197197
return false;
198198
}
199199

ydb/core/tx/schemeshard/olap/schema/update.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class TOlapSchemaUpdate {
1515
YDB_READONLY_DEF(TOlapColumnFamiliesUpdate, ColumnFamilies);
1616

1717
public:
18-
bool Parse(const NKikimrSchemeOp::TColumnTableSchema& tableSchema, IErrorCollector& errors, bool allowNullKeys = false);
18+
bool Parse(const NKikimrSchemeOp::TColumnTableSchema& tableSchema, IErrorCollector& errors, bool allowNullKeys);
1919
bool Parse(const NKikimrSchemeOp::TAlterColumnTableSchema& alterRequest, IErrorCollector& errors);
2020
};
2121
}

ydb/core/tx/schemeshard/olap/store/store.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ bool TOlapStoreInfo::ParseFromRequest(const NKikimrSchemeOp::TColumnStoreDescrip
153153
preset.SetProtoIndex(protoIndex++);
154154

155155
TOlapSchemaUpdate schemaDiff;
156-
if (!schemaDiff.Parse(presetProto.GetSchema(), errors)) {
156+
if (!schemaDiff.Parse(presetProto.GetSchema(), errors, AppData()->ColumnShardConfig.GetAllowNullableColumnsInPK())) {
157157
return false;
158158
}
159159

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

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,81 @@ Y_UNIT_TEST_SUITE(TOlap) {
9999
TestLs(runtime, "/MyRoot/DirA/DirB/OlapStore", false, NLs::PathExist);
100100
}
101101

102+
Y_UNIT_TEST(CreateTableWithNullableKeysNotAllowed) {
103+
TTestBasicRuntime runtime;
104+
TTestEnv env(runtime);
105+
ui64 txId = 100;
106+
107+
auto& appData = runtime.GetAppData();
108+
appData.ColumnShardConfig.SetAllowNullableColumnsInPK(false);
109+
110+
TestCreateOlapStore(runtime, ++txId, "/MyRoot", R"(
111+
Name: "MyStore"
112+
ColumnShardCount: 1
113+
SchemaPresets {
114+
Name: "default"
115+
Schema {
116+
Columns { Name: "timestamp" Type: "Timestamp" NotNull: true }
117+
Columns { Name: "key1" Type: "Uint32" }
118+
Columns { Name: "data" Type: "Utf8" }
119+
KeyColumnNames: [ "timestamp", "key1" ]
120+
}
121+
}
122+
)", {NKikimrScheme::StatusSchemeError});
123+
env.TestWaitNotification(runtime, txId);
124+
}
125+
126+
Y_UNIT_TEST(CreateTableWithNullableKeys) {
127+
TTestBasicRuntime runtime;
128+
TTestEnv env(runtime);
129+
ui64 txId = 100;
130+
131+
auto& appData = runtime.GetAppData();
132+
appData.ColumnShardConfig.SetAllowNullableColumnsInPK(true);
133+
134+
TestCreateOlapStore(runtime, ++txId, "/MyRoot", R"(
135+
Name: "MyStore"
136+
ColumnShardCount: 1
137+
SchemaPresets {
138+
Name: "default"
139+
Schema {
140+
Columns { Name: "timestamp" Type: "Timestamp" NotNull: true }
141+
Columns { Name: "key1" Type: "Uint32" }
142+
Columns { Name: "data" Type: "Utf8" }
143+
KeyColumnNames: [ "timestamp", "key1" ]
144+
}
145+
}
146+
)");
147+
env.TestWaitNotification(runtime, txId);
148+
149+
TestLs(runtime, "/MyRoot/MyStore", false, NLs::PathExist);
150+
151+
TestMkDir(runtime, ++txId, "/MyRoot", "MyDir");
152+
env.TestWaitNotification(runtime, txId);
153+
154+
TestLs(runtime, "/MyRoot/MyDir", false, NLs::PathExist);
155+
156+
TestCreateColumnTable(runtime, ++txId, "/MyRoot/MyDir", R"(
157+
Name: "MyTable"
158+
ColumnShardCount: 1
159+
Schema {
160+
Columns { Name: "timestamp" Type: "Timestamp" NotNull: true }
161+
Columns { Name: "key1" Type: "Uint32" }
162+
Columns { Name: "data" Type: "Utf8" }
163+
KeyColumnNames: [ "timestamp", "key1" ]
164+
}
165+
)");
166+
env.TestWaitNotification(runtime, txId);
167+
168+
TestLsPathId(runtime, 4, NLs::PathStringEqual("/MyRoot/MyDir/MyTable"));
169+
170+
TestDropColumnTable(runtime, ++txId, "/MyRoot/MyDir", "MyTable");
171+
env.TestWaitNotification(runtime, txId);
172+
173+
TestLs(runtime, "/MyRoot/MyDir/MyTable", false, NLs::PathNotExist);
174+
TestLsPathId(runtime, 4, NLs::PathStringEqual(""));
175+
}
176+
102177
Y_UNIT_TEST(CreateTable) {
103178
TTestBasicRuntime runtime;
104179
TTestEnv env(runtime);
@@ -825,5 +900,5 @@ Y_UNIT_TEST_SUITE(TOlap) {
825900
env.TestWaitNotification(runtime, txId);
826901

827902
TestLs(runtime, "/MyRoot/OlapStore", false, NLs::PathExist);
828-
}
903+
}
829904
}

0 commit comments

Comments
 (0)