From b2b9706ba2408b3fea5c2f2782e60ef0cb26127c Mon Sep 17 00:00:00 2001 From: JackyWoo Date: Tue, 2 Apr 2024 16:07:18 +0800 Subject: [PATCH] Add query progress to table zookeeper --- src/Storages/System/StorageSystemZooKeeper.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Storages/System/StorageSystemZooKeeper.cpp b/src/Storages/System/StorageSystemZooKeeper.cpp index d1bf86ba8ef..604e29df0ec 100644 --- a/src/Storages/System/StorageSystemZooKeeper.cpp +++ b/src/Storages/System/StorageSystemZooKeeper.cpp @@ -622,6 +622,20 @@ Chunk SystemZooKeeperSource::generate() ZooKeeperRetriesControl("", nullptr, retries_seetings, query_status).retryLoop( [&]() { get_responses = get_zookeeper()->tryGet(paths_to_get); }); + /// Add children count to query total rows. We can not get total rows in advance, + /// because it is too heavy to get row count for non exact paths. + /// Please be aware that there might be minor setbacks in the query progress, + /// but overall it should reflect the advancement of the query. + size_t children_count = 0; + for (size_t i = 0, size = get_tasks.size(); i < size; ++i) + { + auto & res = get_responses[i]; + if (res.error == Coordination::Error::ZNONODE) + continue; /// Node was deleted meanwhile. + children_count += res.stat.numChildren; + } + addTotalRowsApprox(children_count); + for (size_t i = 0, size = get_tasks.size(); i < size; ++i) { auto & res = get_responses[i];