diff options
author | Oleg Doronin <dorooleg@yandex.ru> | 2024-02-23 18:31:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-23 18:31:12 +0300 |
commit | c713cd6d38ecda14c312e6e02d429dcf396b81d3 (patch) | |
tree | bc50165bab858cb9fa379dc650d9883ce53be7ca | |
parent | 509834b7c24b6ed6755f56a639082685d68d541a (diff) | |
download | ydb-c713cd6d38ecda14c312e6e02d429dcf396b81d3.tar.gz |
external table content has been decoded for viewer KIKIMR-18798 (#1281)
-rw-r--r-- | ydb/core/viewer/json_describe.h | 38 | ||||
-rw-r--r-- | ydb/core/viewer/ya.make | 1 |
2 files changed, 39 insertions, 0 deletions
diff --git a/ydb/core/viewer/json_describe.h b/ydb/core/viewer/json_describe.h index 709a7e62d2f..ac307452447 100644 --- a/ydb/core/viewer/json_describe.h +++ b/ydb/core/viewer/json_describe.h @@ -3,6 +3,7 @@ #include <ydb/library/actors/core/actor_bootstrapped.h> #include <ydb/library/actors/core/mon.h> #include <ydb/core/base/tablet_pipe.h> +#include <ydb/core/external_sources/external_source_factory.h> #include <ydb/library/services/services.pb.h> #include <ydb/core/tx/schemeshard/schemeshard.h> #include <ydb/core/tx/tx_proxy/proxy.h> @@ -268,6 +269,7 @@ public: headers = Viewer->GetHTTPFORBIDDEN(Event->Get()); } TProtoToJson::ProtoToJson(json, *DescribeResult, JsonSettings); + DecodeExternalTableContent(json); } else { json << "null"; } @@ -276,6 +278,42 @@ public: PassAway(); } + void DecodeExternalTableContent(TStringStream& json) const { + if (!DescribeResult) { + return; + } + + if (!DescribeResult->GetPathDescription().HasExternalTableDescription()) { + return; + } + + const auto& content = DescribeResult->GetPathDescription().GetExternalTableDescription().GetContent(); + if (!content) { + return; + } + + NExternalSource::IExternalSourceFactory::TPtr externalSourceFactory{NExternalSource::CreateExternalSourceFactory({})}; + NJson::TJsonValue root; + const auto& sourceType = DescribeResult->GetPathDescription().GetExternalTableDescription().GetSourceType(); + try { + NJson::ReadJsonTree(json.Str(), &root); + root["PathDescription"]["ExternalTableDescription"].EraseValue("Content"); + auto source = externalSourceFactory->GetOrCreate(sourceType); + auto parameters = source->GetParameters(content); + for (const auto& [key, items]: parameters) { + NJson::TJsonValue array{NJson::EJsonValueType::JSON_ARRAY}; + for (const auto& item: items) { + array.AppendValue(item); + } + root["PathDescription"]["ExternalTableDescription"]["Content"][key] = array; + } + } catch (...) { + BLOG_CRIT("Сan't unpack content for external table: " << sourceType << ", error: " << CurrentExceptionMessage()); + } + json.Clear(); + json << root; + } + void HandleTimeout() { Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPGATEWAYTIMEOUT(Event->Get()), 0, NMon::IEvHttpInfoRes::EContentType::Custom)); PassAway(); diff --git a/ydb/core/viewer/ya.make b/ydb/core/viewer/ya.make index 6041359303e..0f9e767bf7d 100644 --- a/ydb/core/viewer/ya.make +++ b/ydb/core/viewer/ya.make @@ -270,6 +270,7 @@ PEERDIR( ydb/core/blobstorage/base ydb/core/blobstorage/vdisk/common ydb/core/client/server + ydb/core/external_sources ydb/core/graph/api ydb/core/grpc_services ydb/core/grpc_services/local_rpc |