aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoruzhas <uzhas@ydb.tech>2022-10-20 22:06:36 +0300
committeruzhas <uzhas@ydb.tech>2022-10-20 22:06:36 +0300
commit7bea54541741932d4b2ef76a3ca37990b502077f (patch)
tree3ff0a5b9d9320d4629b0b5a1949b879f1e445139
parent79a93b20094b7b8f0042e5cfef6af7d9894efeb7 (diff)
downloadydb-7bea54541741932d4b2ef76a3ca37990b502077f.tar.gz
fix severity in issues, rows_count type
-rw-r--r--ydb/core/public_http/fq_handlers.h45
-rw-r--r--ydb/core/public_http/grpc_request_context_wrapper.cpp2
-rw-r--r--ydb/core/public_http/protos/fq.proto14
3 files changed, 50 insertions, 11 deletions
diff --git a/ydb/core/public_http/fq_handlers.h b/ydb/core/public_http/fq_handlers.h
index 2a7c4da28dc..9e70158f711 100644
--- a/ydb/core/public_http/fq_handlers.h
+++ b/ydb/core/public_http/fq_handlers.h
@@ -23,6 +23,8 @@ using ::google::protobuf::RepeatedPtrField;
#define SIMPLE_COPY_FIELD(field) dst.set_##field(src.field())
#define SIMPLE_COPY_RENAME_FIELD(srcField, dstField) dst.set_##dstField(src.srcField())
+#define SIMPLE_COPY_MUTABLE_OPTIONAL_FIELD(field) if (src.has_##field()) { *dst.mutable_##field() = src.field(); }
+
#define SIMPLE_COPY_MUTABLE_FIELD(field) *dst.mutable_##field() = src.field()
#define SIMPLE_COPY_MUTABLE_RENAME_FIELD(srcField, dstField) *dst.mutable_##dstField() = src.srcField()
@@ -48,18 +50,47 @@ void FqConvert(const T& src, ::google::protobuf::Empty& dst) {
Y_UNUSED(dst);
}
+TString RemapSeverity(int severity) {
+ // values from ydb/library/yql/public/issue/protos/issue_severity.proto
+ switch (severity) {
+ case 0:
+ return "FATAL";
+ case 1:
+ return "ERROR";
+ case 2:
+ return "WARNING";
+ case 3:
+ return "INFO";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+template <typename T, typename U>
+void FqConvert(const RepeatedPtrField<T>& src, RepeatedPtrField<U>& dst);
+
+void FqConvert(const Ydb::Issue::IssueMessage& src, FQHttp::IssueMessage& dst) {
+ SIMPLE_COPY_MUTABLE_OPTIONAL_FIELD(position);
+ SIMPLE_COPY_FIELD(message);
+ SIMPLE_COPY_MUTABLE_OPTIONAL_FIELD(end_position);
+ SIMPLE_COPY_FIELD(issue_code);
+ SIMPLE_COPY_REPEATABLE_FIELD(issues);
+ dst.set_severity(RemapSeverity(src.severity()));
+}
+
template <typename T, typename U>
void FqConvert(const RepeatedPtrField<T>& src, RepeatedPtrField<U>& dst) {
- dst.Reserve(src.size());
+ // append
+ dst.Reserve(dst.size() + src.size());
for (auto& v : src) {
FqConvert(v, *dst.Add());
}
}
void FqConvert(const Ydb::Operations::Operation& src, FQHttp::Error& dst) {
- dst.set_status(static_cast<int>(src.status()));
+ dst.set_status(static_cast<int>(src.status()));
SIMPLE_COPY_RENAME_FIELD(status, message);
- SIMPLE_COPY_MUTABLE_RENAME_FIELD(issues, details);
+ SIMPLE_COPY_REPEATABLE_RENAME_FIELD(issues, details);
}
void FqConvert(const FQHttp::CreateQueryRequest& src, YandexQuery::QueryContent& dst) {
@@ -98,11 +129,10 @@ void FqConvert(const YandexQuery::CreateQueryResult& src, FQHttp::CreateQueryRes
}
void FqConvert(const YandexQuery::CommonMeta& src, FQHttp::QueryMeta& dst) {
- SIMPLE_COPY_MUTABLE_FIELD(created_at);
+ SIMPLE_COPY_MUTABLE_RENAME_FIELD(created_at, started_at);
}
void FqConvert(const YandexQuery::QueryMeta& src, FQHttp::QueryMeta& dst) {
- SIMPLE_COPY_MUTABLE_RENAME_FIELD(submitted_at, started_at);
SIMPLE_COPY_MUTABLE_FIELD(finished_at);
FqConvert(src.common(), dst);
}
@@ -140,8 +170,9 @@ void FqConvert(const YandexQuery::Query& src, FQHttp::GetQueryResult& dst) {
FqConvert(result_meta, *dst.mutable_result_sets()->Add());
}
- SIMPLE_COPY_MUTABLE_RENAME_FIELD(issue, issues);
- dst.mutable_issues()->MergeFrom(src.transient_issue());
+ SIMPLE_COPY_REPEATABLE_RENAME_FIELD(issue, issues);
+ // append transient issues to issues
+ SIMPLE_COPY_REPEATABLE_RENAME_FIELD(transient_issue, issues);
}
void FqConvert(const FQHttp::GetQueryRequest& src, YandexQuery::DescribeQueryRequest& dst) {
diff --git a/ydb/core/public_http/grpc_request_context_wrapper.cpp b/ydb/core/public_http/grpc_request_context_wrapper.cpp
index 6b0fd7ce17b..2b6913259e1 100644
--- a/ydb/core/public_http/grpc_request_context_wrapper.cpp
+++ b/ydb/core/public_http/grpc_request_context_wrapper.cpp
@@ -11,7 +11,7 @@ namespace NKikimr::NPublicHttp {
, DeadlineAt(TInstant::Max())
{
JsonSettings.EnumAsNumbers = false;
- JsonSettings.UI64AsString = true;
+ JsonSettings.UI64AsString = false;
JsonSettings.EmptyRepeated = true;
}
diff --git a/ydb/core/public_http/protos/fq.proto b/ydb/core/public_http/protos/fq.proto
index de1df976412..10e634a28d9 100644
--- a/ydb/core/public_http/protos/fq.proto
+++ b/ydb/core/public_http/protos/fq.proto
@@ -12,14 +12,22 @@ import "ydb/public/api/protos/yq.proto";
////////////////////////////////////////////////////////////
+message IssueMessage {
+ Ydb.Issue.IssueMessage.Position position = 1;
+ string message = 2;
+ Ydb.Issue.IssueMessage.Position end_position = 3;
+ uint32 issue_code = 4;
+ string severity = 5;
+ repeated IssueMessage issues = 6;
+}
+
message Error {
int32 status = 1;
Ydb.StatusIds.StatusCode message = 2;
- repeated Ydb.Issue.IssueMessage details = 3;
+ repeated IssueMessage details = 3;
}
message QueryMeta {
- google.protobuf.Timestamp created_at = 1;
google.protobuf.Timestamp started_at = 2;
google.protobuf.Timestamp finished_at = 3;
}
@@ -64,7 +72,7 @@ message GetQueryResult {
ComputeStatus status = 5;
google.protobuf.StringValue text = 6;
QueryMeta meta = 7;
- repeated Ydb.Issue.IssueMessage issues = 8;
+ repeated IssueMessage issues = 8;
repeated ResultSetMeta result_sets = 9;
}