-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add query live plan flow page to Preview Web UI #26392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add query live plan flow page to Preview Web UI #26392
Conversation
05fdc17 to
acaebec
Compare
|
Please rebase to latest master, note the changes from #26524 |
acaebec to
0846f35
Compare
|
@raunaqmorarka rebase done, resolved the conflicts and addressed changes from #26524. I've also applied the same update for #26440 |
core/trino-web-ui/src/main/resources/webapp-preview/src/components/flow/StepNode.tsx
Outdated
Show resolved
Hide resolved
core/trino-web-ui/src/main/resources/webapp-preview/src/components/flow/RemoteMergeNode.tsx
Outdated
Show resolved
Hide resolved
0846f35 to
b15c5b1
Compare
core/trino-web-ui/src/main/resources/webapp-preview/src/components/flow/StepNode.tsx
Outdated
Show resolved
Hide resolved
core/trino-web-ui/src/main/resources/webapp-preview/src/components/flow/StageNode.tsx
Show resolved
Hide resolved
core/trino-web-ui/src/main/resources/webapp-preview/src/components/flow/StageNode.tsx
Outdated
Show resolved
Hide resolved
core/trino-web-ui/src/main/resources/webapp-preview/src/components/flow/StageNode.tsx
Show resolved
Hide resolved
core/trino-web-ui/src/main/resources/webapp-preview/src/components/flow/StageNode.tsx
Show resolved
Hide resolved
core/trino-web-ui/src/main/resources/webapp-preview/src/components/flow/StageNode.tsx
Outdated
Show resolved
Hide resolved
core/trino-web-ui/src/main/resources/webapp-preview/src/components/flow/RemoteMergeNode.tsx
Outdated
Show resolved
Hide resolved
core/trino-web-ui/src/main/resources/webapp-preview/src/components/flow/StageNode.tsx
Show resolved
Hide resolved
| backgroundColor: 'action.hover', | ||
| }} | ||
| > | ||
| <CardHeader |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to show the stage partitioning (io.trino.sql.planner.PlanFragment#partitioning) in the header or somewhere near the top, similar to how EXPLAIN output of the cli shows it
Fragment 2 [SOURCE]
Output layout: [r_regionkey, r_name, r_comment]
Output partitioning: ROUND_ROBIN (scale writers) []
Output partition count: 100
TableScan[table = tpch:tiny:region]
Layout: [r_regionkey:bigint, r_name:varchar(25), r_comment:varchar(152)]
Estimates: {rows: 5 (459B), cpu: 459, memory: 0B, network: 0B}
r_name := tpch:r_name
r_comment := tpch:r_comment
r_regionkey := tpch:r_regionkey
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering how to visualise it clearly. The stage cards (now called PlanFragmentNodes) are already quite large. Adding too much information will make the flow chart harder to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually this info is something short like SOURCE, ROUND_ROBIN (scale writers), COORDINATOR_ONLY etc.
Please look into it as a follow-up, i'll land the current changes.
b15c5b1 to
3c250ba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a Query live plan flow page to the Preview Web UI, providing a visual flow representation of query execution plans with interactive features. The implementation retains the same functionality as the existing web UI while enhancing it with an updated layout, design, and user experience.
- Creates a comprehensive flow visualization system using React Flow for query execution plans
- Implements three node types: PlanFragmentNode (stages), OperatorNode (operators), and RemoteExchangeNode (connections)
- Adds interactive features including draggable stage nodes and toggle for horizontal/vertical auto layout
Reviewed Changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| utils/utils.ts | Adds formatRows utility function for row count formatting |
| flow/types.ts | Defines TypeScript interfaces for flow components and query status |
| flow/layout.ts | Implements layout engine using Dagre for automatic node positioning |
| flow/flowUtils.ts | Contains utilities for parsing query data and creating flow elements |
| flow/RemoteExchangeNode.tsx | React component for remote exchange connections between stages |
| flow/PlanFragmentNode.tsx | React component for main stage containers with execution statistics |
| flow/OperatorNode.tsx | React component for individual operators within stages |
| flow/HelpMessage.tsx | React component for user guidance and layout controls |
| QueryLivePlan.tsx | Main component orchestrating the live plan visualization |
| QueryDetails.tsx | Updates to enable the live plan tab |
| api.ts | Extends API interfaces with query stage and plan data structures |
| package.json | Adds dependencies for Dagre layout engine and React Flow |
Files not reviewed (1)
- core/trino-web-ui/src/main/resources/webapp-preview/package-lock.json: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| export const parseRemoteSources = (sourceFragmentIds: string | undefined): string[] => { | ||
| if (!sourceFragmentIds || sourceFragmentIds.trim() === '[]') { | ||
| return [] | ||
| } | ||
| try { | ||
| const parsed = JSON.parse(sourceFragmentIds) | ||
| return Array.isArray(parsed) ? parsed : [] | ||
| } catch { | ||
| return sourceFragmentIds | ||
| .replace(/[[\]]/g, '') | ||
| .split(',') | ||
| .map((s) => s.trim()) | ||
| .filter(Boolean) | ||
| } | ||
| } |
Copilot
AI
Sep 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The catch block silently handles JSON parsing errors without logging or providing any indication of what went wrong. Consider adding error logging or a more descriptive fallback mechanism to help with debugging malformed sourceFragmentIds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@koszti why do we have a try/catch on the json parsing here ? Is there a way to do this without relying on exceptions driven logic ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the refactored functionality of the current UI at
| var remoteSources = sourceFragmentIds.replace('[', '').replace(']', '').split(', ') |
The sourceFragmentIds field arrives as a JSON-formatted string (e.g., [1,2,3,4]). In the normal case, it should be parsed as JSON. However, if the string is malformed (for example, provided as a plain comma-separated list) it can still be parsed successfully. This change preserves the original behavior by ensuring compatibility with both valid JSON arrays and simple comma-separated lists.
In my tests, it consistently arrives as JSON, though I’m not certain this is guaranteed in all cases and wanted to keep the original behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use the same logic as before then sourceFragmentIds.replace('[', '').replace(']', '').split(', ') ?
That seems less verbose and less likely to raise suspicion to a reader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np, updated
3c250ba to
c00cd06
Compare
Description
Add Query live plan flow page to the preview UI. Partially addressing #22697
Additional context and related issues
Retains the same functionality as the existing web UI, enhanced with the updated layout, design, and user experience.
Additional features not available in the current UI
Screenshots
Release notes
( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text: