-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
401 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
"metadata": { | ||
"execution_id": "4578ea89-93aa2e63-c0ef36df-b5d4c3c8", | ||
"exec_status": "EXEC_STATUS_COMPLETED", | ||
"script_content": { | ||
"syntax": "SYNTAX_YQL_V1", | ||
"text": "SELECT * FROM `/Root/Test`;" | ||
}, | ||
"result_sets_meta": [ | ||
{ | ||
"columns": [ | ||
{ | ||
"name": "Key", | ||
"type": { | ||
"optional_type": { | ||
"item": { | ||
"type_id": "UINT64" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "Value", | ||
"type": { | ||
"optional_type": { | ||
"item": { | ||
"type_id": "STRING" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"exec_mode": "EXEC_MODE_EXECUTE", | ||
"exec_stats": { | ||
"query_phases": [ | ||
{ | ||
"duration_us": 1421, | ||
"table_access": [ | ||
{ | ||
"name": "/Root/Test", | ||
"reads": { | ||
"rows": 15, | ||
"bytes": 255 | ||
}, | ||
"partitions_count": 1 | ||
} | ||
], | ||
"cpu_time_us": 942, | ||
"affected_shards": 1 | ||
} | ||
], | ||
"compilation": { | ||
"duration_us": 7351, | ||
"cpu_time_us": 6955 | ||
}, | ||
"process_cpu_time_us": 72, | ||
"query_plan": "{}", | ||
"total_duration_us": 9039, | ||
"total_cpu_time_us": 7969 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "json_handlers.h" | ||
#include "query_execute_script.h" | ||
#include "query_fetch_script.h" | ||
|
||
namespace NKikimr::NViewer { | ||
|
||
void InitQueryExecuteScriptJsonHandler(TJsonHandlers& handlers) { | ||
handlers.AddHandler("/query/script/execute", new TJsonHandler<TQueryExecuteScript>(TQueryExecuteScript::GetSwagger())); | ||
} | ||
|
||
void InitQueryFetchScriptJsonHandler(TJsonHandlers& handlers) { | ||
handlers.AddHandler("/query/script/fetch", new TJsonHandler<TQueryFetchScript>(TQueryFetchScript::GetSwagger())); | ||
} | ||
|
||
void InitQueryJsonHandlers(TJsonHandlers& jsonHandlers) { | ||
InitQueryExecuteScriptJsonHandler(jsonHandlers); | ||
InitQueryFetchScriptJsonHandler(jsonHandlers); | ||
} | ||
|
||
} // namespace NKikimr::NViewer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#pragma once | ||
#include "json_local_rpc.h" | ||
#include <ydb/core/grpc_services/rpc_calls.h> | ||
#include <ydb/core/viewer/yaml/yaml.h> | ||
#include <ydb/public/api/grpc/ydb_query_v1.grpc.pb.h> | ||
#include <ydb/public/api/grpc/ydb_operation_v1.grpc.pb.h> | ||
|
||
namespace NKikimr { | ||
|
||
namespace NRpcService { | ||
|
||
template<> | ||
void SetRequestSyncOperationMode<Ydb::Query::ExecuteScriptRequest>(Ydb::Query::ExecuteScriptRequest& request) { | ||
request.mutable_operation_params()->set_operation_mode(Ydb::Operations::OperationParams::ASYNC); | ||
} | ||
|
||
} | ||
|
||
namespace NViewer { | ||
|
||
using TQueryExecuteScriptRpc = TJsonLocalRpc<Ydb::Query::ExecuteScriptRequest, | ||
Ydb::Operations::Operation, | ||
Ydb::Operations::Operation, | ||
Ydb::Query::V1::QueryService, | ||
NKikimr::NGRpcService::TGrpcRequestNoOperationCall<Ydb::Query::ExecuteScriptRequest, Ydb::Operations::Operation>>; | ||
|
||
class TQueryExecuteScript : public TQueryExecuteScriptRpc { | ||
public: | ||
using TBase = TQueryExecuteScriptRpc; | ||
|
||
TQueryExecuteScript(IViewer* viewer, NMon::TEvHttpInfo::TPtr& ev) | ||
: TBase(viewer, ev) | ||
{ | ||
AllowedMethods = {HTTP_METHOD_POST}; | ||
} | ||
|
||
static YAML::Node GetSwagger() { | ||
YAML::Node node = YAML::Load(R"___( | ||
post: | ||
tags: | ||
- script query | ||
summary: Execute script | ||
description: Execute script | ||
requestBody: | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
database: | ||
type: string | ||
required: true | ||
script_content: | ||
type: object | ||
properties: | ||
text: | ||
type: string | ||
description: query text | ||
required: true | ||
syntax: | ||
type: string | ||
description: | | ||
syntax: | ||
* `SYNTAX_YQL_V1` | ||
* `SYNTAX_PG` | ||
required: false | ||
exec_mode: | ||
type: string | ||
description: | | ||
exec_mode: | ||
* `EXEC_MODE_PARSE` | ||
* `EXEC_MODE_VALIDATE` | ||
* `EXEC_MODE_EXPLAIN` | ||
* `EXEC_MODE_EXECUTE` | ||
required: true | ||
responses: | ||
200: | ||
description: OK | ||
content: | ||
application/json: | ||
schema: {} | ||
400: | ||
description: Bad Request | ||
403: | ||
description: Forbidden | ||
504: | ||
description: Gateway Timeout | ||
)___"); | ||
node["get"]["responses"]["200"]["content"]["application/json"]["schema"] = TProtoToYaml::ProtoToYamlSchema<Ydb::Operations::Operation>(); | ||
return node; | ||
} | ||
}; | ||
|
||
} | ||
} |
Oops, something went wrong.