Skip to content

Commit

Permalink
Merge pull request #9905 from pdet/fix_pb_again
Browse files Browse the repository at this point in the history
Fix progress bar (again)
  • Loading branch information
Mytherin committed Dec 6, 2023
2 parents 6867e58 + 51dce8d commit 89a2ef9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/parallel/executor.cpp
Expand Up @@ -584,6 +584,7 @@ bool Executor::GetPipelinesProgress(double &current_progress, uint64_t &current_
vector<double> progress;
vector<idx_t> cardinality;
total_cardinality = 0;
current_cardinality = 0;
for (auto &pipeline : pipelines) {
double child_percentage;
idx_t child_cardinality;
Expand All @@ -595,15 +596,16 @@ bool Executor::GetPipelinesProgress(double &current_progress, uint64_t &current_
cardinality.push_back(child_cardinality);
total_cardinality += child_cardinality;
}
current_cardinality = 0;
if (total_cardinality == 0) {
return true;
}
current_progress = 0;

for (size_t i = 0; i < progress.size(); i++) {
D_ASSERT(progress[i] <= 100);
current_cardinality += double(progress[i]) * double(cardinality[i]) / double(100);
current_progress += progress[i] * double(cardinality[i]) / double(total_cardinality);
D_ASSERT(current_cardinality < total_cardinality);
}
return true;
} // LCOV_EXCL_STOP
Expand Down
6 changes: 3 additions & 3 deletions test/api/test_progress_bar.cpp
Expand Up @@ -57,7 +57,7 @@ class TestProgressBar {
}
};

TEST_CASE("Test Progress Bar Fast", "[api]") {
TEST_CASE("Test Progress Bar Fast", "[progress-bar]") {
DuckDB db(nullptr);
Connection con(db);
REQUIRE_NOTHROW(con.context->GetQueryProgress());
Expand Down Expand Up @@ -126,7 +126,7 @@ TEST_CASE("Test Progress Bar Fast", "[api]") {
REQUIRE_NO_FAIL(*result);
}

TEST_CASE("Test Progress Bar", "[api][.]") {
TEST_CASE("Test Progress Bar", "[progress-bar][.]") {
DuckDB db(nullptr);
Connection con(db);
TestProgressBar test_progress(con.context.get());
Expand Down Expand Up @@ -190,7 +190,7 @@ TEST_CASE("Test Progress Bar", "[api][.]") {
REQUIRE_NO_FAIL(*result);
}

TEST_CASE("Test Progress Bar CSV", "[api][.]") {
TEST_CASE("Test Progress Bar CSV", "[progress-bar][.]") {
DuckDB db(nullptr);
Connection con(db);

Expand Down

0 comments on commit 89a2ef9

Please sign in to comment.