diff options
author | ilnaz <ilnaz@ydb.tech> | 2022-08-19 20:29:07 +0300 |
---|---|---|
committer | ilnaz <ilnaz@ydb.tech> | 2022-08-19 20:29:07 +0300 |
commit | 15aaae743152b9028f65881844fe03193b2ff764 (patch) | |
tree | 6e8998803f6f0346d93d01069a54b5706fff378b | |
parent | 8c4dc3020d322d5d0cfe311b267568213fa7865b (diff) | |
download | ydb-15aaae743152b9028f65881844fe03193b2ff764.tar.gz |
Omit non-strict storage settings in table description
-rw-r--r-- | ydb/core/tx/schemeshard/ut_export.cpp | 95 | ||||
-rw-r--r-- | ydb/core/ydb_convert/table_description.cpp | 24 |
2 files changed, 115 insertions, 4 deletions
diff --git a/ydb/core/tx/schemeshard/ut_export.cpp b/ydb/core/tx/schemeshard/ut_export.cpp index 952063bd8a..4640ae4ae7 100644 --- a/ydb/core/tx/schemeshard/ut_export.cpp +++ b/ydb/core/tx/schemeshard/ut_export.cpp @@ -248,6 +248,101 @@ Y_UNIT_TEST_SUITE(TExportToS3Tests) { )"); } + Y_UNIT_TEST(ShouldOmitNonStrictStorageSettings) { + TPortManager portManager; + const ui16 port = portManager.GetPort(); + + TS3Mock s3Mock({}, TS3Mock::TSettings(port)); + UNIT_ASSERT(s3Mock.Start()); + + TTestBasicRuntime runtime; + TTestEnv env(runtime); + + TString scheme; + runtime.SetObserverFunc([&scheme](TTestActorRuntimeBase&, TAutoPtr<IEventHandle>& ev) { + if (!scheme && ev->GetTypeRewrite() == NWrappers::TEvS3Wrapper::EvPutObjectRequest) { + const auto* msg = ev->Get<NWrappers::TEvS3Wrapper::TEvPutObjectRequest>(); + scheme = msg->Body; + } + + return TTestActorRuntime::EEventAction::PROCESS; + }); + + const TVector<TString> tables = {R"( + Name: "Table" + Columns { Name: "key" Type: "Utf8" } + Columns { Name: "value" Type: "Utf8" } + KeyColumnNames: ["key"] + PartitionConfig { + ColumnFamilies { + Id: 0 + StorageConfig { + SysLog { + PreferredPoolKind: "hdd-1" + AllowOtherKinds: true + } + Log { + PreferredPoolKind: "hdd-1" + AllowOtherKinds: true + } + Data { + PreferredPoolKind: "hdd-1" + AllowOtherKinds: true + } + } + } + } + )"}; + + const TString request = Sprintf(R"( + ExportToS3Settings { + endpoint: "localhost:%d" + scheme: HTTP + items { + source_path: "/MyRoot/Table" + destination_prefix: "" + } + } + )", port); + + Run(runtime, env, tables, request); + + UNIT_ASSERT_NO_DIFF(scheme, R"(columns { + name: "key" + type { + optional_type { + item { + type_id: UTF8 + } + } + } +} +columns { + name: "value" + type { + optional_type { + item { + type_id: UTF8 + } + } + } +} +primary_key: "key" +storage_settings { + store_external_blobs: DISABLED +} +column_families { + name: "default" + compression: COMPRESSION_NONE +} +partitioning_settings { + partitioning_by_size: DISABLED + partitioning_by_load: DISABLED + min_partitions_count: 1 +} +)"); + } + void CancelShouldSucceed(TDelayFunc delayFunc) { TPortManager portManager; const ui16 port = portManager.GetPort(); diff --git a/ydb/core/ydb_convert/table_description.cpp b/ydb/core/ydb_convert/table_description.cpp index e00200b745..08f634760d 100644 --- a/ydb/core/ydb_convert/table_description.cpp +++ b/ydb/core/ydb_convert/table_description.cpp @@ -19,6 +19,20 @@ static NProtoBuf::Timestamp MillisecToProtoTimeStamp(ui64 ms) { return timestamp; } +template <typename TStoragePoolHolder> +using TAddStoragePoolFunc = Ydb::Table::StoragePool* (TStoragePoolHolder::*)(); + +template <typename TStoragePoolHolder> +static void FillStoragePool(TStoragePoolHolder* out, TAddStoragePoolFunc<TStoragePoolHolder> func, + const NKikimrSchemeOp::TStorageSettings& in) +{ + if (in.GetAllowOtherKinds()) { + return; + } + + std::invoke(func, out)->set_media(in.GetPreferredPoolKind()); +} + template <typename TYdbProto> void FillColumnDescriptionImpl(TYdbProto& out, NKikimrMiniKQL::TType& splitKeyType, const NKikimrSchemeOp::TTableDescription& in) { @@ -469,14 +483,16 @@ void FillStorageSettingsImpl(TYdbProto& out, settings->set_store_external_blobs(Ydb::FeatureFlag::DISABLED); if (family.HasStorageConfig()) { + using StorageSettings = Ydb::Table::StorageSettings; + if (family.GetStorageConfig().HasSysLog()) { - settings->mutable_tablet_commit_log0()->set_media(family.GetStorageConfig().GetSysLog().GetPreferredPoolKind()); + FillStoragePool(settings, &StorageSettings::mutable_tablet_commit_log0, family.GetStorageConfig().GetSysLog()); } if (family.GetStorageConfig().HasLog()) { - settings->mutable_tablet_commit_log1()->set_media(family.GetStorageConfig().GetLog().GetPreferredPoolKind()); + FillStoragePool(settings, &StorageSettings::mutable_tablet_commit_log1, family.GetStorageConfig().GetLog()); } if (family.GetStorageConfig().HasExternal()) { - settings->mutable_external()->set_media(family.GetStorageConfig().GetExternal().GetPreferredPoolKind()); + FillStoragePool(settings, &StorageSettings::mutable_external, family.GetStorageConfig().GetExternal()); } const ui32 externalThreshold = family.GetStorageConfig().GetExternalThreshold(); @@ -545,7 +561,7 @@ void FillColumnFamiliesImpl(TYdbProto& out, } if (family.HasStorageConfig() && family.GetStorageConfig().HasData()) { - r->mutable_data()->set_media(family.GetStorageConfig().GetData().GetPreferredPoolKind()); + FillStoragePool(r, &Ydb::Table::ColumnFamily::mutable_data, family.GetStorageConfig().GetData()); } if (family.HasColumnCodec()) { |