MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / getQueryDescription

Function getQueryDescription

src/Server/GRPCServer.cpp:320–343  ·  view source on GitHub ↗

Generates a description of a query by a specified query info. This description is used for logging only.

Source from the content-addressed store, hash-verified

318 /// Generates a description of a query by a specified query info.
319 /// This description is used for logging only.
320 String getQueryDescription(const GRPCQueryInfo & query_info)
321 {
322 String str;
323 if (!query_info.query().empty())
324 {
325 std::string_view query = query_info.query();
326 constexpr size_t max_query_length_to_log = 64;
327 if (query.length() > max_query_length_to_log)
328 query.remove_suffix(query.length() - max_query_length_to_log);
329 if (size_t format_pos = query.find(" FORMAT "); format_pos != String::npos)
330 query.remove_suffix(query.length() - format_pos - strlen(" FORMAT "));
331 str.append("\"").append(query);
332 if (query != query_info.query())
333 str.append("...");
334 str.append("\"");
335 }
336 if (!query_info.query_id().empty())
337 str.append(str.empty() ? "" : ", ").append("query_id: ").append(query_info.query_id());
338 if (!query_info.input_data().empty())
339 str.append(str.empty() ? "" : ", ").append("input_data: ").append(std::to_string(query_info.input_data().size())).append(" bytes");
340 if (query_info.external_tables_size())
341 str.append(str.empty() ? "" : ", ").append("external tables: ").append(std::to_string(query_info.external_tables_size()));
342 return str;
343 }
344
345 /// Generates a description of a result.
346 /// This description is used for logging only.

Callers 1

receiveQueryMethod · 0.85

Calls 7

to_stringFunction · 0.50
emptyMethod · 0.45
queryMethod · 0.45
lengthMethod · 0.45
findMethod · 0.45
appendMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected