-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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: Add display_pg_json for LogicalPlan #9789
Conversation
b122581
to
0ba2786
Compare
cc @andygrove Could you help to review this? It helps us to do further debugging for query optimizer. |
This looks pretty awesome -- thank you @liurenjie1024 I am behind on reviews this week but if no one beats me to it I will review this PR in the next day or two |
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.
Thanks @liurenjie1024 - I think this is a really neat feature.
I had a few suggestions on how to improve the code, but I think it could also be merged as is and we can clean it up as a follow on.
Let me know what you want to do.
Thanks again!
@@ -221,6 +229,488 @@ impl<'a, 'b> TreeNodeVisitor for GraphvizVisitor<'a, 'b> { | |||
} | |||
} | |||
|
|||
/// Formats plans to display as postgresql plan json format. |
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 suggest we add a link here to the spec of the postgresql plan format
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've mentioned that there is no formal spec for this format. But it seems that the format is relative simple, it mainly requires Node Type
as name, Output
as schema, and Plans
property as children. Others are not required and visualizer can display them in misc. I have an example in comments for it.
@@ -1302,6 +1303,26 @@ impl LogicalPlan { | |||
Wrapper(self) | |||
} | |||
|
|||
/// Return a `format`able structure that produces plan in postgresql JSON format. |
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.
Likewise here it would be nice to add a link to the spec
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.
See comments above.
Thanks @liurenjie1024 -- I'll plan to merge this tomorrow unless anyone else would like to comment |
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 very cool. Thanks @liurenjie1024
* feat: Add display_pg_json for LogicalPlan * Fix lints * Fix comments * Fix format
Which issue does this PR close?
Related #3606
Rationale for this change
This comment reminds me to have a try on pg json plan, and the visualizer look great to me since we don't need to consider style, but just nodes.
What changes are included in this PR?
Add a method to convert logical plan to postgresql json plan format, and tested in dalibo.
Are these changes tested?
Tested in unittest.
Are there any user-facing changes?
No.