mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-14 11:33:46 +00:00
ffc1fca296
This allows starting and stopping separately each protocol server without restarting ClickHouse. This also allows adding or removing `listen_host` entries, which start and stops servers for all enabled ports. When stopping a server, the listening socket is immediately closed (and available for another server). Protocols with persistent connections try to wait for any currently running query to finish before closing the connection, but idle connection are closed quickly (depending on how often the protocol is polled). An extra ProfileEvent is added, `MainConfigLoads`, it is incremented every time the configuration is reloaded. This helps when trying to assess whether the new configuration was applied.
175 lines
5.2 KiB
Protocol Buffer
175 lines
5.2 KiB
Protocol Buffer
/* This file describes gRPC protocol supported in ClickHouse.
|
|
*
|
|
* To use this protocol a client should send one or more messages of the QueryInfo type
|
|
* and then receive one or more messages of the Result type.
|
|
* According to that the service provides four methods for that:
|
|
* ExecuteQuery(QueryInfo) returns (Result)
|
|
* ExecuteQueryWithStreamInput(stream QueryInfo) returns (Result)
|
|
* ExecuteQueryWithStreamOutput(QueryInfo) returns (stream Result)
|
|
* ExecuteQueryWithStreamIO(stream QueryInfo) returns (stream Result)
|
|
* It's up to the client to choose which method to use.
|
|
* For example, ExecuteQueryWithStreamInput() allows the client to add data multiple times
|
|
* while executing a query, which is suitable for inserting many rows.
|
|
*/
|
|
|
|
syntax = "proto3";
|
|
|
|
package clickhouse.grpc;
|
|
|
|
message NameAndType {
|
|
string name = 1;
|
|
string type = 2;
|
|
}
|
|
|
|
// Describes an external table - a table which will exists only while a query is executing.
|
|
message ExternalTable {
|
|
// Name of the table. If omitted, "_data" is used.
|
|
string name = 1;
|
|
|
|
// Columns of the table. Types are required, names can be omitted. If the names are omitted, "_1", "_2", ... is used.
|
|
repeated NameAndType columns = 2;
|
|
|
|
// Data to insert to the external table.
|
|
// If a method with streaming input (i.e. ExecuteQueryWithStreamInput() or ExecuteQueryWithStreamIO()) is used,
|
|
// then data for insertion to the same external table can be split between multiple QueryInfos.
|
|
bytes data = 3;
|
|
|
|
// Format of the data to insert to the external table.
|
|
string format = 4;
|
|
|
|
// Settings for executing that insertion, applied after QueryInfo.settings.
|
|
map<string, string> settings = 5;
|
|
}
|
|
|
|
enum CompressionAlgorithm {
|
|
NO_COMPRESSION = 0;
|
|
DEFLATE = 1;
|
|
GZIP = 2;
|
|
STREAM_GZIP = 3;
|
|
}
|
|
|
|
enum CompressionLevel {
|
|
COMPRESSION_NONE = 0;
|
|
COMPRESSION_LOW = 1;
|
|
COMPRESSION_MEDIUM = 2;
|
|
COMPRESSION_HIGH = 3;
|
|
}
|
|
|
|
message Compression {
|
|
CompressionAlgorithm algorithm = 1;
|
|
CompressionLevel level = 2;
|
|
}
|
|
|
|
// Information about a query which a client sends to a ClickHouse server.
|
|
// The first QueryInfo can set any of the following fields. Extra QueryInfos only add extra data.
|
|
// In extra QueryInfos only `input_data`, `external_tables`, `next_query_info` and `cancel` fields can be set.
|
|
message QueryInfo {
|
|
string query = 1;
|
|
string query_id = 2;
|
|
map<string, string> settings = 3;
|
|
|
|
// Default database.
|
|
string database = 4;
|
|
|
|
// Input data, used both as data for INSERT query and as data for the input() function.
|
|
bytes input_data = 5;
|
|
|
|
// Delimiter for input_data, inserted between input_data from adjacent QueryInfos.
|
|
bytes input_data_delimiter = 6;
|
|
|
|
// Default output format. If not specified, 'TabSeparated' is used.
|
|
string output_format = 7;
|
|
|
|
repeated ExternalTable external_tables = 8;
|
|
|
|
string user_name = 9;
|
|
string password = 10;
|
|
string quota = 11;
|
|
|
|
// Works exactly like sessions in the HTTP protocol.
|
|
string session_id = 12;
|
|
bool session_check = 13;
|
|
uint32 session_timeout = 14;
|
|
|
|
// Set `cancel` to true to stop executing the query.
|
|
bool cancel = 15;
|
|
|
|
// If true there will be at least one more QueryInfo in the input stream.
|
|
// `next_query_info` is allowed to be set only if a method with streaming input (i.e. ExecuteQueryWithStreamInput() or ExecuteQueryWithStreamIO()) is used.
|
|
bool next_query_info = 16;
|
|
|
|
/// Controls how a ClickHouse server will compress query execution results before sending back to the client.
|
|
/// If not set the compression settings from the configuration file will be used.
|
|
Compression result_compression = 17;
|
|
}
|
|
|
|
enum LogsLevel {
|
|
LOG_NONE = 0;
|
|
LOG_FATAL = 1;
|
|
LOG_CRITICAL = 2;
|
|
LOG_ERROR = 3;
|
|
LOG_WARNING = 4;
|
|
LOG_NOTICE = 5;
|
|
LOG_INFORMATION = 6;
|
|
LOG_DEBUG = 7;
|
|
LOG_TRACE = 8;
|
|
}
|
|
|
|
message LogEntry {
|
|
uint32 time = 1;
|
|
uint32 time_microseconds = 2;
|
|
uint64 thread_id = 3;
|
|
string query_id = 4;
|
|
LogsLevel level = 5;
|
|
string source = 6;
|
|
string text = 7;
|
|
}
|
|
|
|
message Progress {
|
|
uint64 read_rows = 1;
|
|
uint64 read_bytes = 2;
|
|
uint64 total_rows_to_read = 3;
|
|
uint64 written_rows = 4;
|
|
uint64 written_bytes = 5;
|
|
}
|
|
|
|
message Stats {
|
|
uint64 rows = 1;
|
|
uint64 blocks = 2;
|
|
uint64 allocated_bytes = 3;
|
|
bool applied_limit = 4;
|
|
uint64 rows_before_limit = 5;
|
|
}
|
|
|
|
message Exception {
|
|
int32 code = 1;
|
|
string name = 2;
|
|
string display_text = 3;
|
|
string stack_trace = 4;
|
|
}
|
|
|
|
// Result of execution of a query which is sent back by the ClickHouse server to the client.
|
|
message Result {
|
|
// Output of the query, represented in the `output_format` or in a format specified in `query`.
|
|
bytes output = 1;
|
|
bytes totals = 2;
|
|
bytes extremes = 3;
|
|
|
|
repeated LogEntry logs = 4;
|
|
Progress progress = 5;
|
|
Stats stats = 6;
|
|
|
|
// Set by the ClickHouse server if there was an exception thrown while executing.
|
|
Exception exception = 7;
|
|
|
|
// Set by the ClickHouse server if executing was cancelled by the `cancel` field in QueryInfo.
|
|
bool cancelled = 8;
|
|
}
|
|
|
|
service ClickHouse {
|
|
rpc ExecuteQuery(QueryInfo) returns (Result) {}
|
|
rpc ExecuteQueryWithStreamInput(stream QueryInfo) returns (Result) {}
|
|
rpc ExecuteQueryWithStreamOutput(QueryInfo) returns (stream Result) {}
|
|
rpc ExecuteQueryWithStreamIO(stream QueryInfo) returns (stream Result) {}
|
|
}
|