@@ -208,49 +208,27 @@ impl LazyFrame {
208
208
}
209
209
210
210
/// Return a String describing the naive (un-optimized) logical plan.
211
- pub fn describe_plan ( & self ) -> String {
212
- self . logical_plan . describe ( )
211
+ pub fn describe_plan ( & self ) -> PolarsResult < String > {
212
+ Ok ( self . clone ( ) . to_alp ( ) ? . describe ( ) )
213
213
}
214
214
215
215
/// Return a String describing the naive (un-optimized) logical plan in tree format.
216
- pub fn describe_plan_tree ( & self ) -> String {
217
- self . logical_plan . describe_tree_format ( )
218
- }
219
-
220
- fn optimized_plan_ir ( & self ) -> PolarsResult < IRPlan > {
221
- let mut expr_arena = Arena :: with_capacity ( 64 ) ;
222
- let mut lp_arena = Arena :: with_capacity ( 64 ) ;
223
- let lp_top = self . clone ( ) . optimize_with_scratch (
224
- & mut lp_arena,
225
- & mut expr_arena,
226
- & mut vec ! [ ] ,
227
- true ,
228
- ) ?;
229
-
230
- Ok ( IRPlan :: new ( lp_top, lp_arena, expr_arena) )
231
- }
232
-
233
- fn optimized_plan ( & self ) -> PolarsResult < DslPlan > {
234
- let IRPlan {
235
- lp_top,
236
- mut lp_arena,
237
- expr_arena,
238
- } = self . optimized_plan_ir ( ) ?;
239
- Ok ( node_to_lp ( lp_top, & expr_arena, & mut lp_arena) )
216
+ pub fn describe_plan_tree ( & self ) -> PolarsResult < String > {
217
+ Ok ( self . clone ( ) . to_alp ( ) ?. describe_tree_format ( ) )
240
218
}
241
219
242
220
/// Return a String describing the optimized logical plan.
243
221
///
244
222
/// Returns `Err` if optimizing the logical plan fails.
245
223
pub fn describe_optimized_plan ( & self ) -> PolarsResult < String > {
246
- Ok ( self . optimized_plan_ir ( ) ?. describe ( ) )
224
+ Ok ( self . clone ( ) . to_alp_optimized ( ) ?. describe ( ) )
247
225
}
248
226
249
227
/// Return a String describing the optimized logical plan in tree format.
250
228
///
251
229
/// Returns `Err` if optimizing the logical plan fails.
252
230
pub fn describe_optimized_plan_tree ( & self ) -> PolarsResult < String > {
253
- Ok ( self . optimized_plan ( ) ?. describe_tree_format ( ) )
231
+ Ok ( self . clone ( ) . to_alp_optimized ( ) ?. describe_tree_format ( ) )
254
232
}
255
233
256
234
/// Return a String describing the logical plan.
@@ -261,7 +239,7 @@ impl LazyFrame {
261
239
if optimized {
262
240
self . describe_optimized_plan ( )
263
241
} else {
264
- Ok ( self . describe_plan ( ) )
242
+ self . describe_plan ( )
265
243
}
266
244
}
267
245
@@ -532,15 +510,16 @@ impl LazyFrame {
532
510
self . optimize_with_scratch ( lp_arena, expr_arena, & mut vec ! [ ] , false )
533
511
}
534
512
535
- pub fn to_alp_optimized ( self ) -> PolarsResult < ( Node , Arena < IR > , Arena < AExpr > ) > {
513
+ pub fn to_alp_optimized ( self ) -> PolarsResult < IRPlan > {
536
514
let mut lp_arena = Arena :: with_capacity ( 16 ) ;
537
515
let mut expr_arena = Arena :: with_capacity ( 16 ) ;
538
516
let node =
539
517
self . optimize_with_scratch ( & mut lp_arena, & mut expr_arena, & mut vec ! [ ] , false ) ?;
540
- Ok ( ( node, lp_arena, expr_arena) )
518
+
519
+ Ok ( IRPlan :: new ( node, lp_arena, expr_arena) )
541
520
}
542
521
543
- pub fn to_alp ( self ) -> PolarsResult < ( Node , Arena < IR > , Arena < AExpr > ) > {
522
+ pub fn to_alp ( self ) -> PolarsResult < IRPlan > {
544
523
self . logical_plan . to_alp ( )
545
524
}
546
525
0 commit comments