Browse Source

Fix kv init 'It is not allowed to create not null data column' 23-3 error (#2118)

kungurtsev 1 year ago
parent
commit
d9db5d6a97

+ 1 - 0
.gitignore

@@ -75,3 +75,4 @@ util/all_util.cpp
 util/charset/all_charset.cpp
 
 list_result.log
+bin/config.json

+ 5 - 5
ydb/docs/en/core/reference/ydb-cli/workload-kv.md

@@ -46,13 +46,13 @@ The following command is used to create a table:
 
 ```yql
 CREATE TABLE `kv_test`(
-    c0 Uint64 NOT NULL,
-    c1 Uint64 NOT NULL,
+    c0 Uint64,
+    c1 Uint64,
     ...
-    cI Uint64 NOT NULL,
-    cI+1 String NOT NULL,
+    cI Uint64,
+    cI+1 String,
     ...
-    cN String NOT NULL,
+    cN String,
     PRIMARY KEY(c0, c1, ... cK)) WITH (
         AUTO_PARTITIONING_BY_LOAD = ENABLED,
         AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = partsNum,

+ 5 - 5
ydb/docs/ru/core/reference/ydb-cli/workload-kv.md

@@ -46,13 +46,13 @@
 
 ```yql
 CREATE TABLE `kv_test`(
-    c0 Uint64 NOT NULL,
-    c1 Uint64 NOT NULL,
+    c0 Uint64,
+    c1 Uint64,
     ...
-    cI Uint64 NOT NULL,
-    cI+1 String NOT NULL,
+    cI Uint64,
+    cI+1 String,
     ...
-    cN String NOT NULL,
+    cN String,
     PRIMARY KEY(c0, c1, ... cK)) WITH (
         AUTO_PARTITIONING_BY_LOAD = ENABLED,
         AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = partsNum,

+ 9 - 2
ydb/library/workload/kv_workload.cpp

@@ -78,11 +78,18 @@ void AddResultSet(const NYdb::TResultSet& resultSet, TVector<TRow>& rows) {
 
         for (size_t col = 0; col < parser.ColumnsCount(); col++) {
             auto& valueParser = parser.ColumnParser(col);
+            bool optional = valueParser.GetKind() == NYdb::TTypeParser::ETypeKind::Optional; 
+            if (optional) {
+                valueParser.OpenOptional();
+            }
             if (valueParser.GetPrimitiveType() == NYdb::EPrimitiveType::Uint64) {
                 row.Ints.push_back(valueParser.GetUint64());
             } else {
                 row.Strings.push_back(valueParser.GetString());
             }
+            if (optional) {
+                valueParser.CloseOptional();
+            }
         }
 
         rows.push_back(std::move(row));
@@ -147,9 +154,9 @@ std::string TKvWorkloadGenerator::GetDDLQueries() const {
 
     for (size_t i = 0; i < Params.ColumnsCnt; ++i) {
         if (i < Params.IntColumnsCnt) {
-            ss << "c" << i << " Uint64 NOT NULL, ";
+            ss << "c" << i << " Uint64, ";
         } else {
-            ss << "c" << i << " String NOT NULL, ";
+            ss << "c" << i << " String, ";
         }
     }