From 717f75a7318e2dd016fcfe7371ef3a70b986ac75 Mon Sep 17 00:00:00 2001 From: Nikolay Shumkov Date: Mon, 12 Feb 2024 08:26:06 +0300 Subject: [PATCH 1/8] Fixes --- .../tx/schemeshard/ut_export/ut_export.cpp | 66 ++++++++++++++++++- ydb/core/ydb_convert/table_description.cpp | 57 +++++++++++++++- ydb/public/api/protos/ydb_table.proto | 9 +++ 3 files changed, 128 insertions(+), 4 deletions(-) diff --git a/ydb/core/tx/schemeshard/ut_export/ut_export.cpp b/ydb/core/tx/schemeshard/ut_export/ut_export.cpp index 4a8ad8b32170..049a2c776724 100644 --- a/ydb/core/tx/schemeshard/ut_export/ut_export.cpp +++ b/ydb/core/tx/schemeshard/ut_export/ut_export.cpp @@ -281,8 +281,42 @@ Y_UNIT_TEST_SUITE(TExportToS3Tests) { const TVector tables = {R"( Name: "Table" - Columns { Name: "key" Type: "Utf8" } - Columns { Name: "value" Type: "Utf8" } + Columns { + Name: "key" + Type: "Utf8" + DefaultFromLiteral { + type { + optional_type { + item { + type_id: UTF8 + } + } + } + value { + items { + text_value: "b" + } + } + } + } + Columns { + Name: "value" + Type: "Utf8" + DefaultFromLiteral { + type { + optional_type { + item { + type_id: UTF8 + } + } + } + value { + items { + text_value: "a" + } + } + } + } KeyColumnNames: ["key"] PartitionConfig { ColumnFamilies { @@ -331,6 +365,20 @@ Y_UNIT_TEST_SUITE(TExportToS3Tests) { } } not_null: false + from_literal { + type { + optional_type { + item { + type_id: UTF8 + } + } + } + value { + items { + text_value: "b" + } + } + } } columns { name: "value" @@ -342,6 +390,20 @@ columns { } } not_null: false + from_literal { + type { + optional_type { + item { + type_id: UTF8 + } + } + } + value { + items { + text_value: "a" + } + } + } } primary_key: "key" storage_settings { diff --git a/ydb/core/ydb_convert/table_description.cpp b/ydb/core/ydb_convert/table_description.cpp index ad283f387571..d42963246763 100644 --- a/ydb/core/ydb_convert/table_description.cpp +++ b/ydb/core/ydb_convert/table_description.cpp @@ -151,11 +151,11 @@ bool BuildAlterTableAddIndexRequest(const Ydb::Table::AlterTableRequest* req, NK if (flags & NKqpProto::TKqpSchemeOperation::FLAG_PG_MODE) { settings->set_pg_mode(true); } - + if (flags & NKqpProto::TKqpSchemeOperation::FLAG_IF_NOT_EXISTS) { settings->set_if_not_exist(true); } - + settings->set_source_path(req->path()); auto tableIndex = settings->mutable_index(); tableIndex->CopyFrom(req->add_indexes(0)); @@ -390,6 +390,59 @@ static Ydb::Type* AddColumn(Ydb::Table::ColumnMeta* newColumn, const TColumn& co } } newColumn->set_not_null(column.GetNotNull()); + return columnType; +} + +template <> +Ydb::Type* AddColumn(Ydb::Table::ColumnMeta* newColumn, const NKikimrSchemeOp::TColumnDescription& column) { + newColumn->set_name(column.GetName()); + + Ydb::Type* columnType = nullptr; + auto* typeDesc = NPg::TypeDescFromPgTypeName(column.GetType()); + if (typeDesc) { + columnType = newColumn->mutable_type(); + auto* pg = columnType->mutable_pg_type(); + pg->set_type_name(NPg::PgTypeNameFromTypeDesc(typeDesc)); + pg->set_type_modifier(NPg::TypeModFromPgTypeName(column.GetType())); + pg->set_oid(NPg::PgTypeIdFromTypeDesc(typeDesc)); + pg->set_typlen(0); + pg->set_typmod(0); + } else { + NYql::NProto::TypeIds protoType; + if (!NYql::NProto::TypeIds_Parse(column.GetType(), &protoType)) { + throw NYql::TErrorException(NKikimrIssues::TIssuesIds::DEFAULT_ERROR) + << "Got invalid type: " << column.GetType() << " for column: " << column.GetName(); + } + + if (column.GetNotNull()) { + columnType = newColumn->mutable_type(); + } else { + columnType = newColumn->mutable_type()->mutable_optional_type()->mutable_item(); + } + Y_ENSURE(columnType); + if (protoType == NYql::NProto::TypeIds::Decimal) { + auto typeParams = columnType->mutable_decimal_type(); + // TODO: Change TEvDescribeSchemeResult to return decimal params + typeParams->set_precision(22); + typeParams->set_scale(9); + } else { + NMiniKQL::ExportPrimitiveTypeToProto(protoType, *columnType); + } + } + newColumn->set_not_null(column.GetNotNull()); + switch (column.GetDefaultValueCase()) { + case NKikimrSchemeOp::TColumnDescription::kDefaultFromSequence: { + auto from_sequence = newColumn->mutable_from_sequence(); + from_sequence->set_path(column.GetDefaultFromSequence()); + break; + } + case NKikimrSchemeOp::TColumnDescription::kDefaultFromLiteral: { + auto from_literal = newColumn->mutable_from_literal(); + *from_literal = column.GetDefaultFromLiteral(); + break; + } + default: break; + } return columnType; } diff --git a/ydb/public/api/protos/ydb_table.proto b/ydb/public/api/protos/ydb_table.proto index a5d1abcb483c..2068bb16cb9d 100644 --- a/ydb/public/api/protos/ydb_table.proto +++ b/ydb/public/api/protos/ydb_table.proto @@ -333,6 +333,10 @@ message TableProfile { CachingPolicy caching_policy = 7; } +message SequenceDescription { + string path = 1; +} + message ColumnMeta { // Name of column string name = 1; @@ -342,6 +346,11 @@ message ColumnMeta { string family = 3; // Column nullability optional bool not_null = 4; + // Default value policy + oneof default_policy { + SequenceDescription from_sequence = 5; + TypedValue from_literal = 6; + } } message DateTypeColumnModeSettings { From de7977ffd58261ff767630554db060193cf5eb8b Mon Sep 17 00:00:00 2001 From: Nikolay Shumkov Date: Wed, 14 Feb 2024 17:23:21 +0300 Subject: [PATCH 2/8] Fixes --- .../tx/schemeshard/ut_restore/ut_restore.cpp | 14 ++++++++++++ ydb/core/ydb_convert/table_description.cpp | 22 +++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp b/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp index 19b00dba18d3..fcfd6e60cd5f 100644 --- a/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp +++ b/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp @@ -2513,6 +2513,20 @@ Y_UNIT_TEST_SUITE(TImportWithRebootsTests) { columns { name: "key" type { optional_type { item { type_id: UTF8 } } } + from_literal { + type { + optional_type { + item { + type_id: UTF8 + } + } + } + value { + items { + text_value: "b" + } + } + } } columns { name: "value" diff --git a/ydb/core/ydb_convert/table_description.cpp b/ydb/core/ydb_convert/table_description.cpp index d42963246763..af73258c943a 100644 --- a/ydb/core/ydb_convert/table_description.cpp +++ b/ydb/core/ydb_convert/table_description.cpp @@ -432,13 +432,13 @@ Ydb::Type* AddColumn(Ydb::Table::ColumnMeta newColumn->set_not_null(column.GetNotNull()); switch (column.GetDefaultValueCase()) { case NKikimrSchemeOp::TColumnDescription::kDefaultFromSequence: { - auto from_sequence = newColumn->mutable_from_sequence(); - from_sequence->set_path(column.GetDefaultFromSequence()); + auto fromSequence = newColumn->mutable_from_sequence(); + fromSequence->set_path(column.GetDefaultFromSequence()); break; } case NKikimrSchemeOp::TColumnDescription::kDefaultFromLiteral: { - auto from_literal = newColumn->mutable_from_literal(); - *from_literal = column.GetDefaultFromLiteral(); + auto fromLiteral = newColumn->mutable_from_literal(); + *fromLiteral = column.GetDefaultFromLiteral(); break; } default: break; @@ -660,6 +660,20 @@ bool FillColumnDescription(NKikimrSchemeOp::TTableDescription& out, if (!column.family().empty()) { cd->SetFamilyName(column.family()); } + + switch (column.default_policy_case()) { + case Ydb::Table::ColumnMeta::kFromSequence: { + auto fromSequence = cd->MutableDefaultFromSequence(); + *fromSequence = column.from_sequence().path(); + break; + } + case Ydb::Table::ColumnMeta::kFromLiteral: { + auto fromLiteral = cd->MutableDefaultFromLiteral(); + *fromLiteral = column.from_literal(); + break; + } + default: break; + } } return true; From dc773a020065e4c0ec9bfdd2f29a23df3e1d0787 Mon Sep 17 00:00:00 2001 From: Nikolay Shumkov Date: Thu, 15 Feb 2024 16:05:07 +0300 Subject: [PATCH 3/8] Fixes --- ydb/core/ydb_convert/table_description.cpp | 10 ---------- ydb/public/api/protos/ydb_table.proto | 5 ----- 2 files changed, 15 deletions(-) diff --git a/ydb/core/ydb_convert/table_description.cpp b/ydb/core/ydb_convert/table_description.cpp index af73258c943a..06ac95052123 100644 --- a/ydb/core/ydb_convert/table_description.cpp +++ b/ydb/core/ydb_convert/table_description.cpp @@ -431,11 +431,6 @@ Ydb::Type* AddColumn(Ydb::Table::ColumnMeta } newColumn->set_not_null(column.GetNotNull()); switch (column.GetDefaultValueCase()) { - case NKikimrSchemeOp::TColumnDescription::kDefaultFromSequence: { - auto fromSequence = newColumn->mutable_from_sequence(); - fromSequence->set_path(column.GetDefaultFromSequence()); - break; - } case NKikimrSchemeOp::TColumnDescription::kDefaultFromLiteral: { auto fromLiteral = newColumn->mutable_from_literal(); *fromLiteral = column.GetDefaultFromLiteral(); @@ -662,11 +657,6 @@ bool FillColumnDescription(NKikimrSchemeOp::TTableDescription& out, } switch (column.default_policy_case()) { - case Ydb::Table::ColumnMeta::kFromSequence: { - auto fromSequence = cd->MutableDefaultFromSequence(); - *fromSequence = column.from_sequence().path(); - break; - } case Ydb::Table::ColumnMeta::kFromLiteral: { auto fromLiteral = cd->MutableDefaultFromLiteral(); *fromLiteral = column.from_literal(); diff --git a/ydb/public/api/protos/ydb_table.proto b/ydb/public/api/protos/ydb_table.proto index 2068bb16cb9d..281c9db4dfd1 100644 --- a/ydb/public/api/protos/ydb_table.proto +++ b/ydb/public/api/protos/ydb_table.proto @@ -333,10 +333,6 @@ message TableProfile { CachingPolicy caching_policy = 7; } -message SequenceDescription { - string path = 1; -} - message ColumnMeta { // Name of column string name = 1; @@ -348,7 +344,6 @@ message ColumnMeta { optional bool not_null = 4; // Default value policy oneof default_policy { - SequenceDescription from_sequence = 5; TypedValue from_literal = 6; } } From a94410a011c435c98f4f6c5ced671a0ea54b0a96 Mon Sep 17 00:00:00 2001 From: Nikolay Shumkov Date: Thu, 15 Feb 2024 20:42:01 +0300 Subject: [PATCH 4/8] Fixes --- .../tx/schemeshard/ut_restore/ut_restore.cpp | 64 +++++++++++++++---- 1 file changed, 50 insertions(+), 14 deletions(-) diff --git a/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp b/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp index fcfd6e60cd5f..db4d260f5cc5 100644 --- a/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp +++ b/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp @@ -373,6 +373,56 @@ Y_UNIT_TEST_SUITE(TRestoreTests) { NKqp::CompareYson(data.YsonStr, content); } + Y_UNIT_TEST_WITH_COMPRESSION(ShouldSucceedWithDefaultFromLiteral) { + TTestBasicRuntime runtime; + + const auto data = GenerateTestData(Codec, "a", 1); + + Restore(runtime, R"( + Name: "Table" + Columns { Name: "key" Type: "Utf8" } + Columns { + Name: "value" + Type: "Utf8" + DefaultFromLiteral { + type { + optional_type { + item { + type_id: UTF8 + } + } + } + value { + items { + text_value: "value1" + } + } + } + } + KeyColumnNames: ["key"] + )", {}); + + auto writeRow = [&](TString key) { + NKikimrMiniKQL::TResult result; + TString error; + NKikimrProto::EReplyStatus status = LocalMiniKQL(runtime, TTestTxConfig::FakeHiveTablets, Sprintf(R"( + ( + (let key '( '('key (Utf8 '%s) ) ) ) + (let row '( ) ) + (return (AsList (UpdateRow '__user__Table key row) )) + ) + )", key.c_str()), result, error); + + UNIT_ASSERT_VALUES_EQUAL_C(status, NKikimrProto::EReplyStatus::OK, error); + UNIT_ASSERT_VALUES_EQUAL(error, ""); + }; + + writeRow("a1"); + + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); + NKqp::CompareYson(data.YsonStr, content); + } + Y_UNIT_TEST_WITH_COMPRESSION(ShouldSucceedOnMultiShardTable) { TTestBasicRuntime runtime; @@ -2513,20 +2563,6 @@ Y_UNIT_TEST_SUITE(TImportWithRebootsTests) { columns { name: "key" type { optional_type { item { type_id: UTF8 } } } - from_literal { - type { - optional_type { - item { - type_id: UTF8 - } - } - } - value { - items { - text_value: "b" - } - } - } } columns { name: "value" From 5a909e627b14d00d8cf7bf54d21b7668c3aedf68 Mon Sep 17 00:00:00 2001 From: Nikolay Shumkov Date: Fri, 16 Feb 2024 16:33:44 +0300 Subject: [PATCH 5/8] Fixes --- .../tx/schemeshard/ut_restore/ut_restore.cpp | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp b/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp index db4d260f5cc5..f871843156b5 100644 --- a/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp +++ b/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -400,27 +401,18 @@ Y_UNIT_TEST_SUITE(TRestoreTests) { } } KeyColumnNames: ["key"] - )", {}); - - auto writeRow = [&](TString key) { - NKikimrMiniKQL::TResult result; - TString error; - NKikimrProto::EReplyStatus status = LocalMiniKQL(runtime, TTestTxConfig::FakeHiveTablets, Sprintf(R"( - ( - (let key '( '('key (Utf8 '%s) ) ) ) - (let row '( ) ) - (return (AsList (UpdateRow '__user__Table key row) )) - ) - )", key.c_str()), result, error); - - UNIT_ASSERT_VALUES_EQUAL_C(status, NKikimrProto::EReplyStatus::OK, error); - UNIT_ASSERT_VALUES_EQUAL(error, ""); - }; + )", {data}); - writeRow("a1"); + { + TString result = NKikimr::NDataShard::NKqpHelpers::KqpSimpleExec( + runtime, Q_(R"("UPSERT INTO `/MyRoot/Table` (key) VALUES ("a"))")); + UNIT_ASSERT_VALUES_EQUAL(result, ""); + } - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); - NKqp::CompareYson(data.YsonStr, content); + { + TString result = NKikimr::NDataShard::NKqpHelpers::KqpSimpleExec(runtime, "SELECT * FROM `/MyRoot/Table`;"); + UNIT_ASSERT_C(false, result); + } } Y_UNIT_TEST_WITH_COMPRESSION(ShouldSucceedOnMultiShardTable) { From b028a9308ed2e8ff4d9504c23e1204c65be3ab2a Mon Sep 17 00:00:00 2001 From: Nikolay Shumkov Date: Fri, 16 Feb 2024 18:49:19 +0300 Subject: [PATCH 6/8] Fixes --- .../tx/schemeshard/ut_restore/ut_restore.cpp | 44 +++++++++++++++---- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp b/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp index f871843156b5..65dd591e4de4 100644 --- a/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp +++ b/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp @@ -403,16 +403,44 @@ Y_UNIT_TEST_SUITE(TRestoreTests) { KeyColumnNames: ["key"] )", {data}); - { - TString result = NKikimr::NDataShard::NKqpHelpers::KqpSimpleExec( - runtime, Q_(R"("UPSERT INTO `/MyRoot/Table` (key) VALUES ("a"))")); - UNIT_ASSERT_VALUES_EQUAL(result, ""); - } + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); + NKqp::CompareYson(data.YsonStr, content); - { - TString result = NKikimr::NDataShard::NKqpHelpers::KqpSimpleExec(runtime, "SELECT * FROM `/MyRoot/Table`;"); - UNIT_ASSERT_C(false, result); + const auto desc = DescribePath(runtime, "/MyRoot/Table", true, true); + UNIT_ASSERT_VALUES_EQUAL(desc.GetStatus(), NKikimrScheme::StatusSuccess); + + const auto& table = desc.GetPathDescription().GetTable(); + + for (const auto& column: table.GetColumns()) { + if (column.GetName() == "value") { + switch (column.GetDefaultValueCase()) { + case NKikimrSchemeOp::TColumnDescription::kDefaultFromLiteral: { + const auto& fromLiteral = column.GetDefaultFromLiteral(); + + TString str; + google::protobuf::TextFormat::PrintToString(fromLiteral, &str); + + TString result = R"(type { + optional_type { + item { + type_id: UTF8 + } + } +} +value { + items { + text_value: "value1" + } +} +)"; + UNIT_ASSERT_VALUES_EQUAL_C(str, result, "Invalid default value"); + return; + } + default: break; + } + } } + UNIT_ASSERT_C(false, "Invalid default value"); } Y_UNIT_TEST_WITH_COMPRESSION(ShouldSucceedOnMultiShardTable) { From 1ed4119de6776d5400a9fe2562e3f5b56dccaa02 Mon Sep 17 00:00:00 2001 From: Nikolay Shumkov Date: Sun, 18 Feb 2024 22:09:40 +0300 Subject: [PATCH 7/8] Fixes --- .../tx/schemeshard/ut_restore/ut_restore.cpp | 140 ++++++++++++++---- ydb/core/ydb_convert/table_description.cpp | 2 +- ydb/public/api/protos/ydb_table.proto | 3 +- 3 files changed, 111 insertions(+), 34 deletions(-) diff --git a/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp b/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp index 65dd591e4de4..15d9a933abc6 100644 --- a/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp +++ b/ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -374,6 +373,39 @@ Y_UNIT_TEST_SUITE(TRestoreTests) { NKqp::CompareYson(data.YsonStr, content); } + bool CheckDefaultFromLiteral(const NKikimrSchemeOp::TTableDescription& desc) { + for (const auto& column: desc.GetColumns()) { + if (column.GetName() == "value") { + switch (column.GetDefaultValueCase()) { + case NKikimrSchemeOp::TColumnDescription::kDefaultFromLiteral: { + const auto& fromLiteral = column.GetDefaultFromLiteral(); + + TString str; + google::protobuf::TextFormat::PrintToString(fromLiteral, &str); + + TString result = R"(type { + optional_type { + item { + type_id: UTF8 + } + } +} +value { + items { + text_value: "value1" + } +} +)"; + return str == result; + } + default: break; + } + break; + } + } + return false; + } + Y_UNIT_TEST_WITH_COMPRESSION(ShouldSucceedWithDefaultFromLiteral) { TTestBasicRuntime runtime; @@ -411,36 +443,7 @@ Y_UNIT_TEST_SUITE(TRestoreTests) { const auto& table = desc.GetPathDescription().GetTable(); - for (const auto& column: table.GetColumns()) { - if (column.GetName() == "value") { - switch (column.GetDefaultValueCase()) { - case NKikimrSchemeOp::TColumnDescription::kDefaultFromLiteral: { - const auto& fromLiteral = column.GetDefaultFromLiteral(); - - TString str; - google::protobuf::TextFormat::PrintToString(fromLiteral, &str); - - TString result = R"(type { - optional_type { - item { - type_id: UTF8 - } - } -} -value { - items { - text_value: "value1" - } -} -)"; - UNIT_ASSERT_VALUES_EQUAL_C(str, result, "Invalid default value"); - return; - } - default: break; - } - } - } - UNIT_ASSERT_C(false, "Invalid default value"); + UNIT_ASSERT_C(CheckDefaultFromLiteral(table), "Invalid default value"); } Y_UNIT_TEST_WITH_COMPRESSION(ShouldSucceedOnMultiShardTable) { @@ -799,6 +802,81 @@ value { TestGetImport(runtime, txId, "/MyRoot"); } + Y_UNIT_TEST(ShouldRestoreDefaultValuesFromLiteral) { + TPortManager portManager; + const ui16 port = portManager.GetPort(); + + TS3Mock s3Mock({}, TS3Mock::TSettings(port)); + UNIT_ASSERT(s3Mock.Start()); + + TTestBasicRuntime runtime; + TTestEnv env(runtime); + ui64 txId = 100; + + runtime.SetLogPriority(NKikimrServices::DATASHARD_BACKUP, NActors::NLog::PRI_TRACE); + runtime.SetLogPriority(NKikimrServices::DATASHARD_RESTORE, NActors::NLog::PRI_TRACE); + runtime.SetLogPriority(NKikimrServices::EXPORT, NActors::NLog::PRI_TRACE); + runtime.SetLogPriority(NKikimrServices::IMPORT, NActors::NLog::PRI_TRACE); + + TestCreateTable(runtime, ++txId, "/MyRoot", R"( + Name: "Original" + Columns { Name: "key" Type: "Utf8" } + Columns { + Name: "value" + Type: "Utf8" + DefaultFromLiteral { + type { + optional_type { + item { + type_id: UTF8 + } + } + } + value { + items { + text_value: "value1" + } + } + } + } + KeyColumnNames: ["key"] + )"); + env.TestWaitNotification(runtime, txId); + + TestExport(runtime, ++txId, "/MyRoot", Sprintf(R"( + ExportToS3Settings { + endpoint: "localhost:%d" + scheme: HTTP + items { + source_path: "/MyRoot/Original" + destination_prefix: "" + } + } + )", port)); + env.TestWaitNotification(runtime, txId); + TestGetExport(runtime, txId, "/MyRoot"); + + TestImport(runtime, ++txId, "/MyRoot", Sprintf(R"( + ImportFromS3Settings { + endpoint: "localhost:%d" + scheme: HTTP + items { + source_prefix: "" + destination_path: "/MyRoot/Restored" + } + } + )", port)); + env.TestWaitNotification(runtime, txId); + TestGetImport(runtime, txId, "/MyRoot"); + + const auto desc = DescribePath(runtime, "/MyRoot/Restored", true, true); + UNIT_ASSERT_VALUES_EQUAL(desc.GetStatus(), NKikimrScheme::StatusSuccess); + + const auto& table = desc.GetPathDescription().GetTable(); + + UNIT_ASSERT_C(CheckDefaultFromLiteral(table), "Invalid default value"); + } + Y_UNIT_TEST(ExportImportPg) { TTestBasicRuntime runtime; TTestEnv env(runtime, TTestEnvOptions().EnableTablePgTypes(true)); diff --git a/ydb/core/ydb_convert/table_description.cpp b/ydb/core/ydb_convert/table_description.cpp index 06ac95052123..fad7525d2d3e 100644 --- a/ydb/core/ydb_convert/table_description.cpp +++ b/ydb/core/ydb_convert/table_description.cpp @@ -656,7 +656,7 @@ bool FillColumnDescription(NKikimrSchemeOp::TTableDescription& out, cd->SetFamilyName(column.family()); } - switch (column.default_policy_case()) { + switch (column.default_value_policy_case()) { case Ydb::Table::ColumnMeta::kFromLiteral: { auto fromLiteral = cd->MutableDefaultFromLiteral(); *fromLiteral = column.from_literal(); diff --git a/ydb/public/api/protos/ydb_table.proto b/ydb/public/api/protos/ydb_table.proto index 281c9db4dfd1..30f23e83ccfb 100644 --- a/ydb/public/api/protos/ydb_table.proto +++ b/ydb/public/api/protos/ydb_table.proto @@ -342,8 +342,7 @@ message ColumnMeta { string family = 3; // Column nullability optional bool not_null = 4; - // Default value policy - oneof default_policy { + oneof default_value_policy { TypedValue from_literal = 6; } } From 35ab35bb0c33bc1788b7b002f9b6889e891c985b Mon Sep 17 00:00:00 2001 From: Nikolay Shumkov Date: Mon, 19 Feb 2024 16:43:51 +0300 Subject: [PATCH 8/8] Fixes --- ydb/core/ydb_convert/table_description.cpp | 2 +- ydb/public/api/protos/ydb_table.proto | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ydb/core/ydb_convert/table_description.cpp b/ydb/core/ydb_convert/table_description.cpp index fad7525d2d3e..7912606b9214 100644 --- a/ydb/core/ydb_convert/table_description.cpp +++ b/ydb/core/ydb_convert/table_description.cpp @@ -656,7 +656,7 @@ bool FillColumnDescription(NKikimrSchemeOp::TTableDescription& out, cd->SetFamilyName(column.family()); } - switch (column.default_value_policy_case()) { + switch (column.default_value_case()) { case Ydb::Table::ColumnMeta::kFromLiteral: { auto fromLiteral = cd->MutableDefaultFromLiteral(); *fromLiteral = column.from_literal(); diff --git a/ydb/public/api/protos/ydb_table.proto b/ydb/public/api/protos/ydb_table.proto index 30f23e83ccfb..e878cb5bdf17 100644 --- a/ydb/public/api/protos/ydb_table.proto +++ b/ydb/public/api/protos/ydb_table.proto @@ -342,8 +342,9 @@ message ColumnMeta { string family = 3; // Column nullability optional bool not_null = 4; - oneof default_value_policy { - TypedValue from_literal = 6; + // Column default value option + oneof default_value { + TypedValue from_literal = 5; } }