Skip to content

Commit

Permalink
Merge 71f87bf into eecbfab
Browse files Browse the repository at this point in the history
  • Loading branch information
StekPerepolnen committed Jun 14, 2024
2 parents eecbfab + 71f87bf commit 474c1a4
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions ydb/core/viewer/json_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class TJsonQuery : public TViewerPipeClient<TJsonQuery> {
TString Stats;
TString Syntax;
TString QueryId;
TString TransactionMode;
bool Direct = false;
bool IsBase64Encode = true;

Expand Down Expand Up @@ -82,6 +83,7 @@ class TJsonQuery : public TViewerPipeClient<TJsonQuery> {
Schema = StringToSchemaType(schemaStr);
Syntax = params.Get("syntax");
QueryId = params.Get("query_id");
TransactionMode = params.Get("transaction_mode");
Direct = FromStringWithDefault<bool>(params.Get("direct"), Direct);
IsBase64Encode = FromStringWithDefault<bool>(params.Get("base64"), true);
}
Expand All @@ -97,6 +99,7 @@ class TJsonQuery : public TViewerPipeClient<TJsonQuery> {
Action = Action.empty() ? requestData["action"].GetStringSafe({}) : Action;
Syntax = Syntax.empty() ? requestData["syntax"].GetStringSafe({}) : Syntax;
QueryId = QueryId.empty() ? requestData["query_id"].GetStringSafe({}) : QueryId;
TransactionMode = TransactionMode.empty() ? requestData["transaction_mode"].GetStringSafe({}) : TransactionMode;
}
return success;
}
Expand Down Expand Up @@ -231,8 +234,6 @@ class TJsonQuery : public TViewerPipeClient<TJsonQuery> {
} else if (Action == "execute-query") {
request.SetAction(NKikimrKqp::QUERY_ACTION_EXECUTE);
request.SetType(NKikimrKqp::QUERY_TYPE_SQL_GENERIC_QUERY);
request.mutable_txcontrol()->mutable_begin_tx()->mutable_serializable_read_write();
request.mutable_txcontrol()->set_commit_tx(true);
request.SetKeepSession(false);
} else if (Action == "explain-query") {
request.SetAction(NKikimrKqp::QUERY_ACTION_EXPLAIN);
Expand All @@ -245,8 +246,6 @@ class TJsonQuery : public TViewerPipeClient<TJsonQuery> {
} else if (Action == "execute-data") {
request.SetAction(NKikimrKqp::QUERY_ACTION_EXECUTE);
request.SetType(NKikimrKqp::QUERY_TYPE_SQL_DML);
request.mutable_txcontrol()->mutable_begin_tx()->mutable_serializable_read_write();
request.mutable_txcontrol()->set_commit_tx(true);
request.SetKeepSession(false);
} else if (Action == "explain" || Action == "explain-ast" || Action == "explain-data") {
request.SetAction(NKikimrKqp::QUERY_ACTION_EXPLAIN);
Expand All @@ -270,6 +269,16 @@ class TJsonQuery : public TViewerPipeClient<TJsonQuery> {
} else if (Syntax == "pg") {
request.SetSyntax(Ydb::Query::Syntax::SYNTAX_PG);
}
if (TransactionMode == "online-read-only") {
request.mutable_txcontrol()->mutable_begin_tx()->mutable_online_read_only();
} else if (TransactionMode == "stale-read-only") {
request.mutable_txcontrol()->mutable_begin_tx()->mutable_stale_read_only();
} else if (TransactionMode == "snapshot-read-only") {
request.mutable_txcontrol()->mutable_begin_tx()->mutable_snapshot_read_only();
} else if (TransactionMode == "serializable-read-write" || Action == "execute-query" || Action == "execute-data") {
request.mutable_txcontrol()->mutable_begin_tx()->mutable_serializable_read_write();
request.mutable_txcontrol()->set_commit_tx(true);
}
ActorIdToProto(SelfId(), event->Record.MutableRequestActorId());
Send(NKqp::MakeKqpProxyID(SelfId().NodeId()), event.Release());
BLOG_TRACE("Query sent");
Expand Down Expand Up @@ -664,6 +673,17 @@ YAML::Node TJsonRequestSwagger<TJsonQuery>::GetSwagger() {
type: string
enum: [profile, full]
required: false
- name: transaction_mode
in: query
description: >
transaction mode:
* `serializable-read-write`
* `online-read-only`
* `stale-read-only`
* `snapshot-read-only`
type: string
enum: [serializable-read-write, online-read-only, stale-read-only, snapshot-read-only]
required: false
- name: direct
in: query
description: force processing query on current node
Expand Down

0 comments on commit 474c1a4

Please sign in to comment.