Skip to content

Commit

Permalink
Decimal and PG support in viewer (ydb-platform#10752)
Browse files Browse the repository at this point in the history
  • Loading branch information
azevaykin committed Dec 6, 2024
1 parent 5337648 commit 18286ff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
14 changes: 11 additions & 3 deletions ydb/core/tablet_flat/flat_executor_db_mon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ class TExecutor::TTxExecutorDbMon : public TTransactionBase<TExecutor> {
str << "<tr>";
for (ui32 column : columns) {
const auto &columnInfo = tableInfo->Columns.find(column)->second;
str << "<th>" << column << ":" << columnInfo.Name << "</th>";
str << "<th>"
<< column << ":" << NScheme::TypeName(columnInfo.PType, columnInfo.PTypeMod)
<< " " << columnInfo.Name
<< "</th>";
}
str << "</tr>";
str << "</thead>";
Expand Down Expand Up @@ -229,12 +232,17 @@ class TExecutor::TTxExecutorDbMon : public TTransactionBase<TExecutor> {
str << "(DyNumber) " << number;
break;
}
case NScheme::NTypeIds::Decimal: {
tuple.Types[i].GetDecimalType().CellValueToStream(tuple.Columns[i].AsValue<std::pair<ui64, i64>>(), str);
break;
}
case NScheme::NTypeIds::Pg: {
str << "(Pg) " << NPg::PgTypeNameFromTypeDesc(tuple.Types[i].GetPgTypeDesc());
auto convert = NPg::PgNativeTextFromNativeBinary(tuple.Columns[i].AsBuf(), tuple.Types[i].GetPgTypeDesc());
str << (!convert.Error ? convert.Str : *convert.Error);
break;
}
default:
str << "<i>unknown type " << tuple.Types[i].GetTypeId() << "</i>";
str << "<i>unknown type " << NScheme::TypeName(tuple.Types[i]) << "</i>";
break;
}
}
Expand Down
11 changes: 10 additions & 1 deletion ydb/core/viewer/viewer_tabletinfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include "json_wb_req.h"
#include <ydb/core/scheme/scheme_types_proto.h>
#include <ydb/core/util/wildcard.h>

namespace NKikimr::NViewer {
Expand Down Expand Up @@ -173,7 +174,15 @@ class TJsonTabletInfo : public TJsonWhiteboardRequest<TEvWhiteboard::TEvTabletSt
return IsBase64Encode ? Base64Encode(cell.AsBuf()) : (TStringBuilder() << '"' << cell.AsBuf() << '"');
case NScheme::NTypeIds::Utf8:
return TStringBuilder() << '"' << cell.AsBuf() << '"';
case NScheme::NTypeIds::Decimal: return "Decimal";
case NScheme::NTypeIds::Decimal: {
NScheme::TTypeInfo typeInfo = NKikimr::NScheme::TypeInfoFromProto(type.GetTypeId(), type.GetTypeInfo());
return typeInfo.GetDecimalType().CellValueToString(cell.AsValue<std::pair<ui64, i64>>());
}
case NScheme::NTypeIds::Pg: {
NScheme::TTypeInfo typeInfo = NKikimr::NScheme::TypeInfoFromProto(type.GetTypeId(), type.GetTypeInfo());
auto convert = NPg::PgNativeTextFromNativeBinary(cell.AsBuf(),typeInfo.GetPgTypeDesc());
return !convert.Error ? convert.Str : *convert.Error;
}
case NScheme::NTypeIds::DyNumber: return "DyNumber";
case NScheme::NTypeIds::Uuid: return "Uuid";
default:
Expand Down

0 comments on commit 18286ff

Please sign in to comment.