@@ -8,14 +8,9 @@ use std::collections::HashMap;
8
8
9
9
use crate :: common:: { ToDotGraph , FG_COLOR } ;
10
10
11
+ #[ derive( Default ) ]
11
12
pub struct PlanToDot { }
12
13
13
- impl Default for PlanToDot {
14
- fn default ( ) -> Self {
15
- PlanToDot { }
16
- }
17
- }
18
-
19
14
impl PlanToDot {
20
15
pub ( crate ) fn to_dot ( & self , scope : & mut Scope , plan : & LogicalPlan < BindingsOp > ) {
21
16
let mut graph_nodes = HashMap :: new ( ) ;
@@ -71,10 +66,10 @@ impl PlanToDot {
71
66
let clauses = [
72
67
lo. limit
73
68
. as_ref ( )
74
- . map ( |e| format ! ( "limit {}" , expr_to_str( & e) ) ) ,
69
+ . map ( |e| format ! ( "limit {}" , expr_to_str( e) ) ) ,
75
70
lo. offset
76
71
. as_ref ( )
77
- . map ( |e| format ! ( "offset {}" , expr_to_str( & e) ) ) ,
72
+ . map ( |e| format ! ( "offset {}" , expr_to_str( e) ) ) ,
78
73
]
79
74
. iter ( )
80
75
. filter_map ( |o| o. as_ref ( ) )
@@ -92,10 +87,7 @@ impl PlanToDot {
92
87
format ! (
93
88
"{{ {} join | {} }}" ,
94
89
kind,
95
- join. on
96
- . as_ref( )
97
- . map( |e| expr_to_str( e) )
98
- . unwrap_or( "" . to_string( ) )
90
+ join. on. as_ref( ) . map( expr_to_str) . unwrap_or( "" . to_string( ) )
99
91
)
100
92
}
101
93
BindingsOp :: BagOp ( _) => "bag op (TODO)" . to_string ( ) ,
@@ -108,9 +100,7 @@ impl PlanToDot {
108
100
. join( " | " ) ,
109
101
)
110
102
}
111
- BindingsOp :: ProjectAll => {
112
- format ! ( "{{project * }}" )
113
- }
103
+ BindingsOp :: ProjectAll => "{project * }" . to_string ( ) ,
114
104
BindingsOp :: ProjectValue ( pv) => {
115
105
format ! ( "{{project value | {} }}" , expr_to_str( & pv. expr) )
116
106
}
@@ -135,8 +125,7 @@ impl PlanToDot {
135
125
}
136
126
BindingsOp :: Sink => "sink" . to_string ( ) ,
137
127
} ;
138
- node. set_shape ( Shape :: Mrecord )
139
- . set_label ( & format ! ( "{label}" ) ) ;
128
+ node. set_shape ( Shape :: Mrecord ) . set_label ( & label. to_string ( ) ) ;
140
129
141
130
node. id ( )
142
131
}
@@ -163,8 +152,8 @@ fn expr_to_str(expr: &ValueExpr) -> String {
163
152
let expr = expr. replace ( '{' , "\\ {" ) ;
164
153
let expr = expr. replace ( '}' , "\\ }" ) ;
165
154
let expr = expr. replace ( '<' , "\\ <" ) ;
166
- let expr = expr . replace ( '>' , " \\ >" ) ;
167
- expr
155
+
156
+ expr. replace ( '>' , " \\ >" )
168
157
}
169
158
}
170
159
}
@@ -206,6 +195,6 @@ impl ToDotGraph<LogicalPlan<BindingsOp>> for PlanToDot {
206
195
self . to_dot ( & mut digraph, plan) ;
207
196
}
208
197
209
- return String :: from_utf8 ( output_bytes) . expect ( "invalid utf8" ) ;
198
+ String :: from_utf8 ( output_bytes) . expect ( "invalid utf8" )
210
199
}
211
200
}
0 commit comments