Skip to content

minor: Ballista showplan helper script#1761

Merged
milenkovicm merged 22 commits into
apache:mainfrom
milenkovicm:feat_scipts
May 25, 2026
Merged

minor: Ballista showplan helper script#1761
milenkovicm merged 22 commits into
apache:mainfrom
milenkovicm:feat_scipts

Conversation

@milenkovicm
Copy link
Copy Markdown
Contributor

@milenkovicm milenkovicm commented May 24, 2026

Ballista plan print CLI helper

What

Adds dev/bin/showplan.sh, a bash CLI utility for quickly inspecting query plans of Ballista jobs directly from the terminal, using the Ballista REST API.

Why

Inspecting a job's logical, physical, or stage plans currently requires manually assembling curl + jq pipelines and knowing which endpoint to hit. This script wraps that into a single ergonomic command, making debugging and plan analysis faster during development.

ballista-cli displays this information but copying and pasting the generated plan is difficult. Furthermore, inspecting the last job plans during development is common and offers a quick way to access this information.

How it works

The script queries the Ballista scheduler REST API (default: http://localhost:50050/) and prints the requested plan for a given job.

Usage:

showplan.sh [job_id] [-a ADDR] [-p] [-l] [-e] [-s [STAGE_ID]] [-w] [-t]

Options:

Flag Description
job_id Optional. Defaults to the most recently started job (resolved via max_by(.start_time) from /api/jobs)
-a ADDR Override the API base URL (default: http://localhost:50050/)
-p Display physical_plan from job info (default)
-l Display logical_plan from job info
-e Display stage_plan (execution plan) from job info
-s [STAGE_ID] Display the physical plan for a specific stage, or all stages if no ID given (from /api/job/{id}/stages)
-w Pipe output through less -S (no line-wrap, horizontal scroll — useful for wide plans)
-t Request tree-rendered plans (?render_tree=true query parameter)

Other details:

  • The separator line dynamically fills the full terminal width (tput cols, falls back to 80)
  • API base URL is normalised to always have exactly one trailing slash
  • Uses set -euo pipefail for safe error handling
image image

@milenkovicm milenkovicm changed the title minor: Ballista plan print CLI helper minor: Ballista showplan hepler script May 24, 2026
@milenkovicm milenkovicm changed the title minor: Ballista showplan hepler script minor: Ballista showplan helper script May 24, 2026
Comment thread dev/bin/showplan.sh Outdated
Comment thread dev/bin/showplan.sh Outdated
Comment thread dev/bin/showplan.sh Outdated
Comment thread dev/bin/showplan.sh Outdated
Comment thread dev/bin/showplan.sh Outdated
Comment thread dev/bin/showplan.sh
STAGES_URL="${API_BASE}api/job/${JOB_ID}/stages"
fi

COLS=$(tput cols 2>/dev/tty || echo 80)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
COLS=$(tput cols 2>/dev/tty || echo 80)
COLS=$(tput cols 2>/dev/null || echo 80)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not work, it will return 80 every time

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ COLS=$(tput cols 2>/dev/null || echo 80)
$ echo $COLS
238

You want errors to be ignored, right ?
The normal way is to write them to /dev/null. It will return 80 only if /dev/null is not existing or your OS user does not have permissions to read that file.

$ ls -la /dev/null 
crw-rw-rw- 1 root root 1, 3 May 12 14:08 /dev/null
$ COLS=$(tput cols 2>/dev/null || echo 80) && echo $COLS
238
$ COLS=$(tput cols 2>/dev/nulllll || echo 80) && echo $COLS
bash: /dev/nulllll: Permission denied
80

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but for some reason it return 80 all the time on my own machine

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will try later

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ COLS=$(tput cols 2>/dev/null || echo 80)
$ echo $COLS
80
$  tput cols
215

for some reason

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor thing we can fix it later if needed

Comment thread dev/bin/showplan.sh Outdated
Comment thread dev/bin/showplan.sh Outdated
Comment thread dev/bin/showplan.sh Outdated
Comment thread dev/bin/showplan.sh Outdated
milenkovicm and others added 19 commits May 25, 2026 10:50
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
@milenkovicm milenkovicm requested a review from martin-g May 25, 2026 12:49
Comment thread dev/bin/showplan.sh Outdated
Comment thread dev/bin/showplan.sh
STAGES_URL="${API_BASE}api/job/${JOB_ID}/stages"
fi

COLS=$(tput cols 2>/dev/tty || echo 80)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ COLS=$(tput cols 2>/dev/null || echo 80)
$ echo $COLS
238

You want errors to be ignored, right ?
The normal way is to write them to /dev/null. It will return 80 only if /dev/null is not existing or your OS user does not have permissions to read that file.

$ ls -la /dev/null 
crw-rw-rw- 1 root root 1, 3 May 12 14:08 /dev/null
$ COLS=$(tput cols 2>/dev/null || echo 80) && echo $COLS
238
$ COLS=$(tput cols 2>/dev/nulllll || echo 80) && echo $COLS
bash: /dev/nulllll: Permission denied
80

Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
@milenkovicm
Copy link
Copy Markdown
Contributor Author

$ COLS=$(tput cols 2>/dev/null || echo 80)
$ echo $COLS
80
$  tput cols
215

@milenkovicm milenkovicm merged commit 65ec1c4 into apache:main May 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants