pub struct PgJsonVisitor<'a, 'b> {
f: &'a mut Formatter<'b>,
objects: HashMap<u32, Value>,
next_id: u32,
with_schema: bool,
parent_ids: Vec<u32>,
}Expand description
Formats plans to display as postgresql plan json format.
There are already many existing visualizer for this format, for example dalibo. Unfortunately, there is no formal spec for this format, but it is widely used in the PostgreSQL community.
Here is an example of the format:
[
{
"Plan": {
"Node Type": "Sort",
"Output": [
"question_1.id",
"question_1.title",
"question_1.text",
"question_1.file",
"question_1.type",
"question_1.source",
"question_1.exam_id"
],
"Sort Key": [
"question_1.id"
],
"Plans": [
{
"Node Type": "Seq Scan",
"Parent Relationship": "Left",
"Relation Name": "question",
"Schema": "public",
"Alias": "question_1",
"Output": [
"question_1.id",
"question_1.title",
"question_1.text",
"question_1.file",
"question_1.type",
"question_1.source",
"question_1.exam_id"
],
"Filter": "(question_1.exam_id = 1)"
}
]
}
}
]Fields§
§f: &'a mut Formatter<'b>§objects: HashMap<u32, Value>A mapping from plan node id to the plan node json representation.
next_id: u32§with_schema: boolIf true, includes summarized schema information
parent_ids: Vec<u32>Holds the ids (as generated from graphviz_builder of all
parent nodes
Implementations§
Source§impl<'a, 'b> PgJsonVisitor<'a, 'b>
impl<'a, 'b> PgJsonVisitor<'a, 'b>
pub fn new(f: &'a mut Formatter<'b>) -> Self
Sourcepub fn with_schema(&mut self, with_schema: bool)
pub fn with_schema(&mut self, with_schema: bool)
Sets a flag which controls if the output schema is displayed
Sourcefn to_json_value(node: &LogicalPlan) -> Value
fn to_json_value(node: &LogicalPlan) -> Value
Converts a logical plan node to a json object.
Trait Implementations§
Source§impl<'n> TreeNodeVisitor<'n> for PgJsonVisitor<'_, '_>
impl<'n> TreeNodeVisitor<'n> for PgJsonVisitor<'_, '_>
Source§type Node = LogicalPlan
type Node = LogicalPlan
The node type which is visitable.
Source§fn f_down(&mut self, node: &'n LogicalPlan) -> Result<TreeNodeRecursion>
fn f_down(&mut self, node: &'n LogicalPlan) -> Result<TreeNodeRecursion>
Invoked while traversing down the tree, before any children are visited.
Default implementation continues the recursion.
Auto Trait Implementations§
impl<'a, 'b> Freeze for PgJsonVisitor<'a, 'b>
impl<'a, 'b> !RefUnwindSafe for PgJsonVisitor<'a, 'b>
impl<'a, 'b> !Send for PgJsonVisitor<'a, 'b>
impl<'a, 'b> !Sync for PgJsonVisitor<'a, 'b>
impl<'a, 'b> Unpin for PgJsonVisitor<'a, 'b>
impl<'a, 'b> !UnwindSafe for PgJsonVisitor<'a, 'b>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more