Skip to content

correctly handle inf values in streaming query #14875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ydb/core/viewer/json_pipe_req.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ TString TViewerPipeClient::GetHTTPOKJSON(const NJson::TJsonValue& response, TIns

TString TViewerPipeClient::GetHTTPOKJSON(const google::protobuf::Message& response, TInstant lastModified) {
TStringStream json;
NProtobufJson::Proto2Json(response, json, Proto2JsonConfig);
Proto2Json(response, json);
return GetHTTPOKJSON(json.Str(), lastModified);
}

Expand Down
11 changes: 11 additions & 0 deletions ydb/core/viewer/json_pipe_req.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,17 @@ class TViewerPipeClient : public TActorBootstrapped<TViewerPipeClient> {
void InitConfig(const TRequestSettings& settings);
void BuildParamsFromJson(TStringBuf data);
void SetupTracing(const TString& handlerName);

template<typename TJson>
void Proto2Json(const NProtoBuf::Message& proto, TJson& json) {
try {
NProtobufJson::Proto2Json(proto, json, Proto2JsonConfig);
}
catch (const std::exception& e) {
json = TStringBuilder() << "error converting " << proto.GetTypeName() << " to json: " << e.what();
}
}

void ClosePipes();
ui32 FailPipeConnect(TTabletId tabletId);

Expand Down
12 changes: 1 addition & 11 deletions ydb/core/viewer/storage_groups.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
#include "json_pipe_req.h"
#include "log.h"
#include "viewer_helper.h"
#include <library/cpp/protobuf/json/proto2json.h>
#include <ydb/library/actors/interconnect/interconnect.h>

namespace NKikimr::NViewer {

using namespace NProtobufJson;

using TNodeId = ui32;
using TGroupId = ui32;

Expand Down Expand Up @@ -2180,14 +2177,7 @@ class TStorageGroups : public TViewerPipeClient {
}
}
AddEvent("RenderingResult");
TStringStream out;
Proto2Json(json, out, {
.EnumMode = TProto2JsonConfig::EnumValueMode::EnumName,
.StringifyNumbers = TProto2JsonConfig::EStringifyNumbersMode::StringifyInt64Always,
.WriteNanAsString = true,
});
AddEvent("ResultReady");
TBase::ReplyAndPassAway(GetHTTPOKJSON(out.Str()));
TBase::ReplyAndPassAway(GetHTTPOKJSON(json));
}

static YAML::Node GetSwagger() {
Expand Down
11 changes: 1 addition & 10 deletions ydb/core/viewer/viewer_cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
#include "viewer.h"
#include "viewer_helper.h"
#include "viewer_tabletinfo.h"
#include <library/cpp/protobuf/json/proto2json.h>

namespace NKikimr::NViewer {

using namespace NProtobufJson;
using namespace NActors;
using namespace NNodeWhiteboard;

Expand Down Expand Up @@ -849,14 +847,7 @@ class TJsonCluster : public TViewerPipeClient {
worstNodes += nodes;
}
ClusterInfo.SetOverall(GetViewerFlag(worstState));
TStringStream out;
Proto2Json(ClusterInfo, out, {
.EnumMode = TProto2JsonConfig::EnumValueMode::EnumName,
.MapAsObject = true,
.StringifyNumbers = TProto2JsonConfig::EStringifyNumbersMode::StringifyInt64Always,
.WriteNanAsString = true,
});
TBase::ReplyAndPassAway(GetHTTPOKJSON(out.Str()));
TBase::ReplyAndPassAway(GetHTTPOKJSON(ClusterInfo));
}

public:
Expand Down
12 changes: 1 addition & 11 deletions ydb/core/viewer/viewer_nodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
#include "viewer_helper.h"
#include "viewer_tabletinfo.h"
#include "wb_group.h"
#include <library/cpp/protobuf/json/proto2json.h>

namespace NKikimr::NViewer {

using namespace NProtobufJson;
using namespace NActors;
using namespace NNodeWhiteboard;

Expand Down Expand Up @@ -3230,15 +3228,7 @@ class TJsonNodes : public TViewerPipeClient {
}
}
AddEvent("RenderingResult");
TStringStream out;
Proto2Json(json, out, {
.EnumMode = TProto2JsonConfig::EnumValueMode::EnumName,
.MapAsObject = true,
.StringifyNumbers = TProto2JsonConfig::EStringifyNumbersMode::StringifyInt64Always,
.WriteNanAsString = true,
});
AddEvent("ResultReady");
TBase::ReplyAndPassAway(GetHTTPOKJSON(out.Str()));
TBase::ReplyAndPassAway(GetHTTPOKJSON(json));
}

static YAML::Node GetSwagger() {
Expand Down
4 changes: 2 additions & 2 deletions ydb/core/viewer/viewer_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ class TJsonQuery : public TViewerPipeClient {
NJson::ReadJsonTree(progress.GetQueryPlan(), &(json["plan"]));
}
if (progress.HasQueryStats()) {
NProtobufJson::Proto2Json(progress.GetQueryStats(), json["stats"]);
Proto2Json(progress.GetQueryStats(), json["stats"]);
}
StreamJsonResponse(json);
}
Expand Down Expand Up @@ -830,7 +830,7 @@ class TJsonQuery : public TViewerPipeClient {
NJson::ReadJsonTree(response.GetQueryPlan(), &(jsonResponse["plan"]));
}
if (response.HasQueryStats()) {
NProtobufJson::Proto2Json(response.GetQueryStats(), jsonResponse["stats"]);
Proto2Json(response.GetQueryStats(), jsonResponse["stats"]);
}
}
catch (const std::exception& ex) {
Expand Down
Loading