Merge pull request #33097 from kssenii/clickhouse-local-send-profile-onfo

clickhouse-local send profile info
This commit is contained in:
alexey-milovidov 2021-12-24 02:29:36 +03:00 committed by GitHub
commit 0e3af2f19a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 71 additions and 7 deletions

View File

@ -214,15 +214,15 @@ bool LocalConnection::poll(size_t)
if (next_packet_type)
return true;
if (send_progress && (state->after_send_progress.elapsedMicroseconds() >= query_context->getSettingsRef().interactive_delay))
{
state->after_send_progress.restart();
next_packet_type = Protocol::Server::Progress;
return true;
}
if (!state->is_finished)
{
if (send_progress && (state->after_send_progress.elapsedMicroseconds() >= query_context->getSettingsRef().interactive_delay))
{
state->after_send_progress.restart();
next_packet_type = Protocol::Server::Progress;
return true;
}
try
{
pollImpl();
@ -282,6 +282,18 @@ bool LocalConnection::poll(size_t)
}
}
if (state->is_finished && !state->sent_profile_info)
{
state->sent_profile_info = true;
if (state->executor)
{
next_packet_type = Protocol::Server::ProfileInfo;
state->profile_info = state->executor->getProfileInfo();
return true;
}
}
if (state->is_finished)
{
finishQuery();
@ -349,6 +361,16 @@ Packet LocalConnection::receivePacket()
next_packet_type.reset();
break;
}
case Protocol::Server::ProfileInfo:
{
if (state->profile_info)
{
packet.profile_info = std::move(*state->profile_info);
state->profile_info.reset();
}
next_packet_type.reset();
break;
}
case Protocol::Server::TableColumns:
{
if (state->columns_description)

View File

@ -35,6 +35,7 @@ struct LocalQueryState
/// Current block to be sent next.
std::optional<Block> block;
std::optional<ColumnsDescription> columns_description;
std::optional<ProfileInfo> profile_info;
/// Is request cancelled
bool is_cancelled = false;
@ -43,6 +44,7 @@ struct LocalQueryState
bool sent_totals = false;
bool sent_extremes = false;
bool sent_progress = false;
bool sent_profile_info = false;
/// To output progress, the difference after the previous sending of progress.
Progress progress;

View File

@ -0,0 +1,32 @@
{
"meta":
[
{
"name": "count()",
"type": "UInt64"
},
{
"name": "n",
"type": "UInt8"
}
],
"data":
[
{
"count()": "1",
"n": 1
}
],
"totals":
{
"count()": "3",
"n": 0
},
"rows": 1,
"rows_before_limit_at_least": 3,
"statistics":

View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
${CLICKHOUSE_LOCAL} --query "SELECT count(), arrayJoin([1, 2, 3]) AS n GROUP BY n WITH TOTALS ORDER BY n LIMIT 1 FORMAT JSON;" 2>&1 | head -32