Skip to content

Commit

Permalink
feat: Add printPlanWithStats API for Task
Browse files Browse the repository at this point in the history
  • Loading branch information
majetideepak committed Feb 27, 2025
1 parent b0d7de9 commit 2878fc1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions velox/exec/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "velox/exec/NestedLoopJoinBuild.h"
#include "velox/exec/OperatorUtils.h"
#include "velox/exec/OutputBufferManager.h"
#include "velox/exec/PlanNodeStats.h"
#include "velox/exec/Task.h"
#include "velox/exec/TraceUtil.h"

Expand Down Expand Up @@ -2433,6 +2434,14 @@ ContinueFuture Task::taskDeletionFuture() {
return std::move(future);
}

std::string Task::printPlanWithStats(bool includeCustomStats) const {
if (planFragment_.planNode) {
return exec::printPlanWithStats(
*planFragment_.planNode, taskStats_, includeCustomStats);
}
return "";
}

std::string Task::toString() const {
std::lock_guard<std::timed_mutex> l(mutex_);
std::stringstream out;
Expand Down
2 changes: 2 additions & 0 deletions velox/exec/Task.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ class Task : public std::enable_shared_from_this<Task> {
spillDirectoryCallback_ = std::move(spillDirectoryCallback);
}

std::string printPlanWithStats(bool includeCustomStats = false) const;

std::string toString() const;

folly::dynamic toJson() const;
Expand Down
2 changes: 1 addition & 1 deletion velox/exec/tests/PrintPlanWithStatsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ TEST_F(PrintPlanWithStatsTest, innerJoinWithTableScan) {
ensureTaskCompletion(task.get());
compareOutputs(
::testing::UnitTest::GetInstance()->current_test_info()->name(),
printPlanWithStats(*op, task->taskStats()),
task->printPlanWithStats(),
{{"-- Project\\[4\\]\\[expressions: \\(c0:INTEGER, ROW\\[\"c0\"\\]\\), \\(p1:BIGINT, plus\\(ROW\\[\"c1\"\\],1\\)\\), \\(p2:BIGINT, plus\\(ROW\\[\"c1\"\\],ROW\\[\"u_c1\"\\]\\)\\)\\] -> c0:INTEGER, p1:BIGINT, p2:BIGINT"},
{" Output: 2000 rows \\(.+\\), Cpu time: .+, Blocked wall time: .+, Peak memory: .+, Memory allocations: .+, Threads: 1, CPU breakdown: B/I/O/F (.+/.+/.+/.+)"},
{" -- HashJoin\\[3\\]\\[INNER c0=u_c0\\] -> c0:INTEGER, c1:BIGINT, u_c1:BIGINT"},
Expand Down

0 comments on commit 2878fc1

Please sign in to comment.