@@ -268,6 +268,7 @@ class TJsonDescribe : public TViewerPipeClient<TJsonDescribe> {
268268 headers = HTTPFORBIDDENJSON;
269269 }
270270 TProtoToJson::ProtoToJson (json, *DescribeResult, JsonSettings);
271+ DecodeExternalTableContent (json);
271272 } else {
272273 json << " null" ;
273274 }
@@ -276,6 +277,41 @@ class TJsonDescribe : public TViewerPipeClient<TJsonDescribe> {
276277 PassAway ();
277278 }
278279
280+ void DecodeExternalTableContent (TStringStream& json) const {
281+ if (!DescribeResult) {
282+ return ;
283+ }
284+
285+ if (!DescribeResult->GetPathDescription ().HasExternalTableDescription ()) {
286+ return ;
287+ }
288+
289+ const auto & content = DescribeResult->GetPathDescription ().GetExternalTableDescription ().GetContent ();
290+ if (!content) {
291+ return ;
292+ }
293+
294+ NJson::TJsonValue root;
295+ const auto & sourceType = DescribeResult->GetPathDescription ().GetExternalTableDescription ().GetSourceType ();
296+ try {
297+ NJson::ReadJsonTree (json.Str (), &root);
298+ root[" PathDescription" ][" ExternalTableDescription" ].EraseValue (" Content" );
299+ auto source = AppData ()->ExternalSourceFactory ->GetOrCreate (sourceType);
300+ auto parameters = source->GetParameters (content);
301+ for (const auto & [key, items]: parameters) {
302+ NJson::TJsonValue array{NJson::EJsonValueType::JSON_ARRAY};
303+ for (const auto & item: items) {
304+ array.AppendValue (item);
305+ }
306+ root[" PathDescription" ][" ExternalTableDescription" ][" Content" ][key] = array;
307+ }
308+ } catch (...) {
309+ BLOG_CRIT (" Сan't unpack content for external table: " << sourceType << " , error: " << CurrentExceptionMessage ());
310+ }
311+ json.Clear ();
312+ json << root;
313+ }
314+
279315 void HandleTimeout () {
280316 Send (Event->Sender , new NMon::TEvHttpInfoRes (Viewer->GetHTTPGATEWAYTIMEOUT (Event->Get ()), 0 , NMon::IEvHttpInfoRes::EContentType::Custom));
281317 PassAway ();
0 commit comments