Skip to content
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

feat: explain a query and output a Graphviz representation of the query plan #18803

Closed
Tracked by #19361
lmatz opened this issue Oct 8, 2024 · 8 comments · Fixed by #19446
Closed
Tracked by #19361

feat: explain a query and output a Graphviz representation of the query plan #18803

lmatz opened this issue Oct 8, 2024 · 8 comments · Fixed by #19446
Assignees
Labels
good first issue Good for newcomers help wanted Issues that need help from contributors priority/low type/feature
Milestone

Comments

@lmatz
Copy link
Contributor

lmatz commented Oct 8, 2024

In the case of a large complex query, a visualized representation can be clearer to diagnose problems, e.g. easier to know which two upstream are joined together if they are separated far away in the output of explain <SQL>.

https://github.com/risingwavelabs/risingwave/blob/main/src/frontend/src/scheduler/distributed/query.rs#L293-L294 output a task-level graphviz representation for debugging usage.

We can enable a query plan representation via the command explain (graphviz) <SQL>.

@github-actions github-actions bot added this to the release-2.1 milestone Oct 8, 2024
@kwannoel
Copy link
Contributor

kwannoel commented Oct 8, 2024

Related: #14168

@kwannoel
Copy link
Contributor

kwannoel commented Oct 8, 2024

And also #17218

@kwannoel
Copy link
Contributor

kwannoel commented Oct 8, 2024

Opening a tracking issue for these improvements to explain.

@kwannoel
Copy link
Contributor

Currently we support structured output, so the major work is complete. We can support graphviz as well, via the DOT format.

This can be done in the following way:

  1. Use serde to convert the IR into petgraph::Graph. https://docs.rs/petgraph/latest/petgraph/. Just enable serde-1 feature flag.
  2. From petgraph::Graph, this can be converted to Dot format: https://docs.rs/petgraph/latest/petgraph/dot/struct.Dot.html.

@kwannoel kwannoel added good first issue Good for newcomers help wanted Issues that need help from contributors labels Nov 13, 2024
@lyang24
Copy link
Contributor

lyang24 commented Nov 18, 2024

Hi @kwannoel , I wound like to attempt on this issue - are we aiming to support logical plan and physical plan as dot format?

Use serde to convert the IR into petgraph::Graph. https://docs.rs/petgraph/latest/petgraph/. Just enable serde-1 feature flag.

looking at the code do we need to implement Deserialize for PrettySerde struct?

@kwannoel
Copy link
Contributor

Hi @kwannoel , I wound like to attempt on this issue - are we aiming to support logical plan and physical plan as dot format?

Yes, via FORMAT DOT.

Use serde to convert the IR into petgraph::Graph. https://docs.rs/petgraph/latest/petgraph/. Just enable serde-1 feature flag.

looking at the code do we need to implement Deserialize for PrettySerde struct?

Yes, either implement Deserialize, or if you need more control over the way PrettySerde gets converted to petgraph::Graph, skip serde and manually convert it.

@lyang24
Copy link
Contributor

lyang24 commented Nov 19, 2024

send a draft - one more q which syntax is better explain (format graphviz) or explain (graphviz)?

@kwannoel
Copy link
Contributor

send a draft - one more q which syntax is better explain (format graphviz) or explain (graphviz)?

Missed this, replied here: #19446 (comment). Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Issues that need help from contributors priority/low type/feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants