Skip to main content

Process GRPC sending

Initializes the stream, sends the request and a set of data in a specified order, receiving one message upon completion

Function ProcessGRPCSending(Val Connection, Val Request, Val Data, Val Session = Undefined, Val Timeout = 10000) Export

ParameterCLI optionTypeRequiredDescription
Connection--connArbitraryExisting connection or connection parameters
Request--reqStructure Of KeyAndValueRequest data. See GetRequestSettings
Data--dataArray Of ArbitraryAn array of strings, collections, binary data, or file paths
Session--sessionStructure Of KeyAndValueSession settings. See GetSessionSettings
Timeout--toutNumberTimeout (in ms)
Returns

Map Of KeyAndValue - Processing result

1C:Enterprise/OneScript code example
URL = "http://localhost:9101";
Login = "bayselonarrend";
Password = "12we...";

Authorization = New Structure(Login, Password);
ConnectionSettings = OPI_ClickHouse.GetGRPCConnectionSettings(URL, Authorization);
Connection = OPI_ClickHouse.CreateGRPCConnection(ConnectionSettings);

QueryText = "INSERT INTO events_stream_test FORMAT JSONEachRow";
DataFormat = "JSON";
CurrentDate = Date("20260101100000");

Request = Undefined;
DataArray = New Array;

Counter = 0;
While Counter < 5 Do

Record = New Structure;
Record.Insert("id" , Counter + 1);
Record.Insert("timestamp" , CurrentDate);
Record.Insert("user_id" , 100 + Counter);
Record.Insert("event_type", "stream_test");
Record.Insert("payload" , "{}");

Record = OPI_Tools.JSONString(Record) + Chars.LF;

If Counter = 0 Then
Request = OPI_ClickHouse.GetRequestSettings(QueryText, "default", , Record, DataFormat);
Else
DataArray.Add(Record);
EndIf;

Counter = Counter + 1;

EndDo;

Result = OPI_ClickHouse.ProcessGRPCSending(Connection, Request, DataArray);
# JSON data can also be passed as a path to a .json file

oint clickhouse ProcessGRPCSending \
--conn "{'auth_type':'basic','user':'bayselonarrend','password':'***','transport':'grpc','address':'http://127.0.0.1:9101'}" \
--req "{'query':'INSERT INTO events_stream_test FORMAT JSONEachRow','database':'default','data':{'id':'1','timestamp':'01/01/2026 10:00:00','user_id':'100','event_type':'stream_test','payload':'{}'},'format':'JSON'}" \
--data "['{\r\n \"'"id\"'": 2,\r\n \"'"timestamp\"'": \"'"2026-01-01T10:00:00\"'",\r\n \"'"user_id\"'": 101,\r\n \"'"event_type\"'": \"'"stream_test\"'",\r\n \"'"payload\"'": \"'"{}\"'"\r\n}\n','{\r\n \"'"id\"'": 3,\r\n \"'"timestamp\"'": \"'"2026-01-01T10:00:00\"'",\r\n \"'"user_id\"'": 102,\r\n \"'"event_type\"'": \"'"stream_test\"'",\r\n \"'"payload\"'": \"'"{}\"'"\r\n}\n','{\r\n \"'"id\"'": 4,\r\n \"'"timestamp\"'": \"'"2026-01-01T10:00:00\"'",\r\n \"'"user_id\"'": 103,\r\n \"'"event_type\"'": \"'"stream_test\"'",\r\n \"'"payload\"'": \"'"{}\"'"\r\n}\n','{\r\n \"'"id\"'": 5,\r\n \"'"timestamp\"'": \"'"2026-01-01T10:00:00\"'",\r\n \"'"user_id\"'": 104,\r\n \"'"event_type\"'": \"'"stream_test\"'",\r\n \"'"payload\"'": \"'"{}\"'"\r\n}\n']"
Result
{
"result": true,
"request_sending": {
"result": true
},
"data_sending": [
{
"result": true
},
{
"result": true
},
{
"result": true
},
{
"result": true
}
],
"received_message": {
"message": {
"cancelled": false,
"exception": {
"code": 0,
"display_text": "",
"name": "",
"stack_trace": ""
},
"extremes": {
"BYTES": ""
},
"logs": [],
"output": {
"BYTES": ""
},
"output_columns": [],
"output_format": "",
"progress": {
"read_bytes": 0,
"read_rows": 0,
"total_rows_to_read": 0,
"written_bytes": 235,
"written_rows": 5
},
"query_id": "8e1a2a7a-8d9f-4346-807a-0bf28c7b23d0",
"stats": {
"allocated_bytes": 0,
"applied_aggregation": false,
"applied_limit": false,
"blocks": 0,
"rows": 0,
"rows_before_aggregation": 0,
"rows_before_limit": 0
},
"time_zone": "Europe/Moscow",
"totals": {
"BYTES": ""
}
},
"result": true
},
"stream_closing": {
"result": true
}
}