Skip to content

Commit 968d8b7

Browse files
Merge pull request ClickHouse#62152 from JackyWoo/add_query_progress_to_table_zookeeper
Add query progress to table zookeeper
2 parents 48a4c40 + 59f061c commit 968d8b7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Storages/System/StorageSystemZooKeeper.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,20 @@ Chunk SystemZooKeeperSource::generate()
622622
ZooKeeperRetriesControl("", nullptr, retries_seetings, query_status).retryLoop(
623623
[&]() { get_responses = get_zookeeper()->tryGet(paths_to_get); });
624624

625+
/// Add children count to query total rows. We can not get total rows in advance,
626+
/// because it is too heavy to get row count for non exact paths.
627+
/// Please be aware that there might be minor setbacks in the query progress,
628+
/// but overall it should reflect the advancement of the query.
629+
size_t children_count = 0;
630+
for (size_t i = 0, size = get_tasks.size(); i < size; ++i)
631+
{
632+
auto & res = get_responses[i];
633+
if (res.error == Coordination::Error::ZNONODE)
634+
continue; /// Node was deleted meanwhile.
635+
children_count += res.stat.numChildren;
636+
}
637+
addTotalRowsApprox(children_count);
638+
625639
for (size_t i = 0, size = get_tasks.size(); i < size; ++i)
626640
{
627641
auto & res = get_responses[i];

0 commit comments

Comments
 (0)