@@ -56,7 +56,7 @@ fn from_optd_schema(optd_schema: &OptdSchema) -> Schema {
56
56
57
57
impl OptdPlanContext < ' _ > {
58
58
#[ async_recursion]
59
- async fn from_optd_table_scan (
59
+ async fn conv_from_optd_table_scan (
60
60
& mut self ,
61
61
node : PhysicalScan ,
62
62
) -> Result < Arc < dyn ExecutionPlan + ' static > > {
@@ -66,12 +66,12 @@ impl OptdPlanContext<'_> {
66
66
Ok ( plan)
67
67
}
68
68
69
- fn from_optd_sort_order_expr (
69
+ fn conv_from_optd_sort_order_expr (
70
70
& mut self ,
71
71
sort_expr : SortOrderExpr ,
72
72
context : & SchemaRef ,
73
73
) -> Result < physical_expr:: PhysicalSortExpr > {
74
- let expr = self . from_optd_expr ( sort_expr. child ( ) , context) ?;
74
+ let expr = self . conv_from_optd_expr ( sort_expr. child ( ) , context) ?;
75
75
Ok ( physical_expr:: PhysicalSortExpr {
76
76
expr,
77
77
options : match sort_expr. order ( ) {
@@ -87,7 +87,7 @@ impl OptdPlanContext<'_> {
87
87
} )
88
88
}
89
89
90
- fn from_optd_agg_expr (
90
+ fn conv_from_optd_agg_expr (
91
91
& mut self ,
92
92
expr : Expr ,
93
93
context : & SchemaRef ,
@@ -101,7 +101,7 @@ impl OptdPlanContext<'_> {
101
101
. children ( )
102
102
. to_vec ( )
103
103
. into_iter ( )
104
- . map ( |expr| self . from_optd_expr ( expr, context) )
104
+ . map ( |expr| self . conv_from_optd_expr ( expr, context) )
105
105
. collect :: < Result < Vec < _ > > > ( ) ?;
106
106
Ok ( create_aggregate_expr (
107
107
& func,
@@ -113,7 +113,7 @@ impl OptdPlanContext<'_> {
113
113
) ?)
114
114
}
115
115
116
- fn from_optd_expr ( & mut self , expr : Expr , context : & SchemaRef ) -> Result < Arc < dyn PhysicalExpr > > {
116
+ fn conv_from_optd_expr ( & mut self , expr : Expr , context : & SchemaRef ) -> Result < Arc < dyn PhysicalExpr > > {
117
117
match expr. typ ( ) {
118
118
OptRelNodeTyp :: ColumnRef => {
119
119
let expr = ColumnRefExpr :: from_rel_node ( expr. into_rel_node ( ) ) . unwrap ( ) ;
@@ -147,7 +147,7 @@ impl OptdPlanContext<'_> {
147
147
. children ( )
148
148
. to_vec ( )
149
149
. into_iter ( )
150
- . map ( |expr| self . from_optd_expr ( expr, context) )
150
+ . map ( |expr| self . conv_from_optd_expr ( expr, context) )
151
151
. collect :: < Result < Vec < _ > > > ( ) ?;
152
152
match func {
153
153
FuncType :: Scalar ( func) => {
@@ -175,13 +175,13 @@ impl OptdPlanContext<'_> {
175
175
OptRelNodeTyp :: LogOp ( typ) => {
176
176
let expr = LogOpExpr :: from_rel_node ( expr. into_rel_node ( ) ) . unwrap ( ) ;
177
177
let mut children = expr. children ( ) . to_vec ( ) . into_iter ( ) ;
178
- let first_expr = self . from_optd_expr ( children. next ( ) . unwrap ( ) , context) ?;
178
+ let first_expr = self . conv_from_optd_expr ( children. next ( ) . unwrap ( ) , context) ?;
179
179
let op = match typ {
180
180
LogOpType :: And => datafusion:: logical_expr:: Operator :: And ,
181
181
LogOpType :: Or => datafusion:: logical_expr:: Operator :: Or ,
182
182
} ;
183
183
children. try_fold ( first_expr, |acc, expr| {
184
- let expr = self . from_optd_expr ( expr, context) ?;
184
+ let expr = self . conv_from_optd_expr ( expr, context) ?;
185
185
Ok (
186
186
Arc :: new ( datafusion:: physical_plan:: expressions:: BinaryExpr :: new (
187
187
acc, op, expr,
@@ -191,8 +191,8 @@ impl OptdPlanContext<'_> {
191
191
}
192
192
OptRelNodeTyp :: BinOp ( op) => {
193
193
let expr = BinOpExpr :: from_rel_node ( expr. into_rel_node ( ) ) . unwrap ( ) ;
194
- let left = self . from_optd_expr ( expr. left_child ( ) , context) ?;
195
- let right = self . from_optd_expr ( expr. right_child ( ) , context) ?;
194
+ let left = self . conv_from_optd_expr ( expr. left_child ( ) , context) ?;
195
+ let right = self . conv_from_optd_expr ( expr. right_child ( ) , context) ?;
196
196
let op = match op {
197
197
BinOpType :: Eq => Operator :: Eq ,
198
198
BinOpType :: Neq => Operator :: NotEq ,
@@ -216,19 +216,19 @@ impl OptdPlanContext<'_> {
216
216
}
217
217
218
218
#[ async_recursion]
219
- async fn from_optd_projection (
219
+ async fn conv_from_optd_projection (
220
220
& mut self ,
221
221
node : PhysicalProjection ,
222
222
) -> Result < Arc < dyn ExecutionPlan + ' static > > {
223
- let input_exec = self . from_optd_plan_node ( node. child ( ) ) . await ?;
223
+ let input_exec = self . conv_from_optd_plan_node ( node. child ( ) ) . await ?;
224
224
let physical_exprs = node
225
225
. exprs ( )
226
226
. to_vec ( )
227
227
. into_iter ( )
228
228
. enumerate ( )
229
229
. map ( |( idx, expr) | {
230
230
Ok ( (
231
- self . from_optd_expr ( expr, & input_exec. schema ( ) ) ?,
231
+ self . conv_from_optd_expr ( expr, & input_exec. schema ( ) ) ?,
232
232
format ! ( "col{}" , idx) ,
233
233
) )
234
234
} )
@@ -241,12 +241,12 @@ impl OptdPlanContext<'_> {
241
241
}
242
242
243
243
#[ async_recursion]
244
- async fn from_optd_filter (
244
+ async fn conv_from_optd_filter (
245
245
& mut self ,
246
246
node : PhysicalFilter ,
247
247
) -> Result < Arc < dyn ExecutionPlan + ' static > > {
248
- let input_exec = self . from_optd_plan_node ( node. child ( ) ) . await ?;
249
- let physical_expr = self . from_optd_expr ( node. cond ( ) , & input_exec. schema ( ) ) ?;
248
+ let input_exec = self . conv_from_optd_plan_node ( node. child ( ) ) . await ?;
249
+ let physical_expr = self . conv_from_optd_expr ( node. cond ( ) , & input_exec. schema ( ) ) ?;
250
250
Ok (
251
251
Arc :: new ( datafusion:: physical_plan:: filter:: FilterExec :: try_new (
252
252
physical_expr,
@@ -256,17 +256,17 @@ impl OptdPlanContext<'_> {
256
256
}
257
257
258
258
#[ async_recursion]
259
- async fn from_optd_sort (
259
+ async fn conv_from_optd_sort (
260
260
& mut self ,
261
261
node : PhysicalSort ,
262
262
) -> Result < Arc < dyn ExecutionPlan + ' static > > {
263
- let input_exec = self . from_optd_plan_node ( node. child ( ) ) . await ?;
263
+ let input_exec = self . conv_from_optd_plan_node ( node. child ( ) ) . await ?;
264
264
let physical_exprs = node
265
265
. exprs ( )
266
266
. to_vec ( )
267
267
. into_iter ( )
268
268
. map ( |expr| {
269
- self . from_optd_sort_order_expr (
269
+ self . conv_from_optd_sort_order_expr (
270
270
SortOrderExpr :: from_rel_node ( expr. into_rel_node ( ) ) . unwrap ( ) ,
271
271
& input_exec. schema ( ) ,
272
272
)
@@ -281,24 +281,24 @@ impl OptdPlanContext<'_> {
281
281
}
282
282
283
283
#[ async_recursion]
284
- async fn from_optd_agg (
284
+ async fn conv_from_optd_agg (
285
285
& mut self ,
286
286
node : PhysicalAgg ,
287
287
) -> Result < Arc < dyn ExecutionPlan + ' static > > {
288
- let input_exec = self . from_optd_plan_node ( node. child ( ) ) . await ?;
288
+ let input_exec = self . conv_from_optd_plan_node ( node. child ( ) ) . await ?;
289
289
let agg_exprs = node
290
290
. aggrs ( )
291
291
. to_vec ( )
292
292
. into_iter ( )
293
- . map ( |expr| self . from_optd_agg_expr ( expr, & input_exec. schema ( ) ) )
293
+ . map ( |expr| self . conv_from_optd_agg_expr ( expr, & input_exec. schema ( ) ) )
294
294
. collect :: < Result < Vec < _ > > > ( ) ?;
295
295
let group_exprs = node
296
296
. groups ( )
297
297
. to_vec ( )
298
298
. into_iter ( )
299
299
. map ( |expr| {
300
300
Ok ( (
301
- self . from_optd_expr ( expr, & input_exec. schema ( ) ) ?,
301
+ self . conv_from_optd_expr ( expr, & input_exec. schema ( ) ) ?,
302
302
"<agg_expr>" . to_string ( ) ,
303
303
) )
304
304
} )
@@ -320,12 +320,12 @@ impl OptdPlanContext<'_> {
320
320
}
321
321
322
322
#[ async_recursion]
323
- async fn from_optd_nested_loop_join (
323
+ async fn conv_from_optd_nested_loop_join (
324
324
& mut self ,
325
325
node : PhysicalNestedLoopJoin ,
326
326
) -> Result < Arc < dyn ExecutionPlan + ' static > > {
327
- let left_exec = self . from_optd_plan_node ( node. left ( ) ) . await ?;
328
- let right_exec = self . from_optd_plan_node ( node. right ( ) ) . await ?;
327
+ let left_exec = self . conv_from_optd_plan_node ( node. left ( ) ) . await ?;
328
+ let right_exec = self . conv_from_optd_plan_node ( node. right ( ) ) . await ?;
329
329
let filter_schema = {
330
330
let fields = left_exec
331
331
. schema ( )
@@ -337,7 +337,7 @@ impl OptdPlanContext<'_> {
337
337
Schema :: new_with_metadata ( fields, HashMap :: new ( ) )
338
338
} ;
339
339
340
- let physical_expr = self . from_optd_expr ( node. cond ( ) , & Arc :: new ( filter_schema. clone ( ) ) ) ?;
340
+ let physical_expr = self . conv_from_optd_expr ( node. cond ( ) , & Arc :: new ( filter_schema. clone ( ) ) ) ?;
341
341
342
342
if let JoinType :: Cross = node. join_type ( ) {
343
343
return Ok ( Arc :: new ( CrossJoinExec :: new ( left_exec, right_exec) )
@@ -375,12 +375,12 @@ impl OptdPlanContext<'_> {
375
375
}
376
376
377
377
#[ async_recursion]
378
- async fn from_optd_hash_join (
378
+ async fn conv_from_optd_hash_join (
379
379
& mut self ,
380
380
node : PhysicalHashJoin ,
381
381
) -> Result < Arc < dyn ExecutionPlan + ' static > > {
382
- let left_exec = self . from_optd_plan_node ( node. left ( ) ) . await ?;
383
- let right_exec = self . from_optd_plan_node ( node. right ( ) ) . await ?;
382
+ let left_exec = self . conv_from_optd_plan_node ( node. left ( ) ) . await ?;
383
+ let right_exec = self . conv_from_optd_plan_node ( node. right ( ) ) . await ?;
384
384
let join_type = match node. join_type ( ) {
385
385
JoinType :: Inner => datafusion:: logical_expr:: JoinType :: Inner ,
386
386
_ => unimplemented ! ( ) ,
@@ -421,7 +421,7 @@ impl OptdPlanContext<'_> {
421
421
}
422
422
423
423
#[ async_recursion]
424
- async fn from_optd_plan_node ( & mut self , node : PlanNode ) -> Result < Arc < dyn ExecutionPlan > > {
424
+ async fn conv_from_optd_plan_node ( & mut self , node : PlanNode ) -> Result < Arc < dyn ExecutionPlan > > {
425
425
let mut schema = OptdSchema ( vec ! [ ] ) ;
426
426
if node. typ ( ) == OptRelNodeTyp :: PhysicalEmptyRelation {
427
427
schema = node. schema ( self . optimizer . unwrap ( ) . optd_optimizer ( ) ) ;
@@ -430,38 +430,38 @@ impl OptdPlanContext<'_> {
430
430
let rel_node_dbg = rel_node. clone ( ) ;
431
431
let result = match & rel_node. typ {
432
432
OptRelNodeTyp :: PhysicalScan => {
433
- self . from_optd_table_scan ( PhysicalScan :: from_rel_node ( rel_node) . unwrap ( ) )
433
+ self . conv_from_optd_table_scan ( PhysicalScan :: from_rel_node ( rel_node) . unwrap ( ) )
434
434
. await
435
435
}
436
436
OptRelNodeTyp :: PhysicalProjection => {
437
- self . from_optd_projection ( PhysicalProjection :: from_rel_node ( rel_node) . unwrap ( ) )
437
+ self . conv_from_optd_projection ( PhysicalProjection :: from_rel_node ( rel_node) . unwrap ( ) )
438
438
. await
439
439
}
440
440
OptRelNodeTyp :: PhysicalFilter => {
441
- self . from_optd_filter ( PhysicalFilter :: from_rel_node ( rel_node) . unwrap ( ) )
441
+ self . conv_from_optd_filter ( PhysicalFilter :: from_rel_node ( rel_node) . unwrap ( ) )
442
442
. await
443
443
}
444
444
OptRelNodeTyp :: PhysicalSort => {
445
- self . from_optd_sort ( PhysicalSort :: from_rel_node ( rel_node) . unwrap ( ) )
445
+ self . conv_from_optd_sort ( PhysicalSort :: from_rel_node ( rel_node) . unwrap ( ) )
446
446
. await
447
447
}
448
448
OptRelNodeTyp :: PhysicalAgg => {
449
- self . from_optd_agg ( PhysicalAgg :: from_rel_node ( rel_node) . unwrap ( ) )
449
+ self . conv_from_optd_agg ( PhysicalAgg :: from_rel_node ( rel_node) . unwrap ( ) )
450
450
. await
451
451
}
452
452
OptRelNodeTyp :: PhysicalNestedLoopJoin ( _) => {
453
- self . from_optd_nested_loop_join (
453
+ self . conv_from_optd_nested_loop_join (
454
454
PhysicalNestedLoopJoin :: from_rel_node ( rel_node) . unwrap ( ) ,
455
455
)
456
456
. await
457
457
}
458
458
OptRelNodeTyp :: PhysicalHashJoin ( _) => {
459
- self . from_optd_hash_join ( PhysicalHashJoin :: from_rel_node ( rel_node) . unwrap ( ) )
459
+ self . conv_from_optd_hash_join ( PhysicalHashJoin :: from_rel_node ( rel_node) . unwrap ( ) )
460
460
. await
461
461
}
462
462
OptRelNodeTyp :: PhysicalCollector ( _) => {
463
463
let node = PhysicalCollector :: from_rel_node ( rel_node) . unwrap ( ) ;
464
- let child = self . from_optd_plan_node ( node. child ( ) ) . await ?;
464
+ let child = self . conv_from_optd_plan_node ( node. child ( ) ) . await ?;
465
465
Ok ( Arc :: new ( CollectorExec :: new (
466
466
child,
467
467
node. group_id ( ) ,
@@ -481,8 +481,8 @@ impl OptdPlanContext<'_> {
481
481
result. with_context ( || format ! ( "when processing {}" , rel_node_dbg) )
482
482
}
483
483
484
- pub async fn from_optd ( & mut self , root_rel : OptRelNodeRef ) -> Result < Arc < dyn ExecutionPlan > > {
485
- self . from_optd_plan_node ( PlanNode :: from_rel_node ( root_rel) . unwrap ( ) )
484
+ pub async fn conv_from_optd ( & mut self , root_rel : OptRelNodeRef ) -> Result < Arc < dyn ExecutionPlan > > {
485
+ self . conv_from_optd_plan_node ( PlanNode :: from_rel_node ( root_rel) . unwrap ( ) )
486
486
. await
487
487
}
488
488
}
0 commit comments