@@ -76,9 +76,10 @@ impl From<&protobuf::PhysicalColumn> for Column {
76
76
/// # Arguments
77
77
///
78
78
/// * `proto` - Input proto with physical sort expression node
79
- /// * `registry` - A registry knows how to build logical expressions out of user-defined function' names
79
+ /// * `registry` - A registry knows how to build logical expressions out of user-defined function names
80
80
/// * `input_schema` - The Arrow schema for the input, used for determining expression data types
81
81
/// when performing type coercion.
82
+ /// * `codec` - An extension codec used to decode custom UDFs.
82
83
pub fn parse_physical_sort_expr (
83
84
proto : & protobuf:: PhysicalSortExprNode ,
84
85
registry : & dyn FunctionRegistry ,
@@ -102,9 +103,10 @@ pub fn parse_physical_sort_expr(
102
103
/// # Arguments
103
104
///
104
105
/// * `proto` - Input proto with vector of physical sort expression node
105
- /// * `registry` - A registry knows how to build logical expressions out of user-defined function' names
106
+ /// * `registry` - A registry knows how to build logical expressions out of user-defined function names
106
107
/// * `input_schema` - The Arrow schema for the input, used for determining expression data types
107
108
/// when performing type coercion.
109
+ /// * `codec` - An extension codec used to decode custom UDFs.
108
110
pub fn parse_physical_sort_exprs (
109
111
proto : & [ protobuf:: PhysicalSortExprNode ] ,
110
112
registry : & dyn FunctionRegistry ,
@@ -123,25 +125,39 @@ pub fn parse_physical_sort_exprs(
123
125
///
124
126
/// # Arguments
125
127
///
126
- /// * `proto` - Input proto with physical window exprression node.
128
+ /// * `proto` - Input proto with physical window expression node.
127
129
/// * `name` - Name of the window expression.
128
- /// * `registry` - A registry knows how to build logical expressions out of user-defined function' names
130
+ /// * `registry` - A registry knows how to build logical expressions out of user-defined function names
129
131
/// * `input_schema` - The Arrow schema for the input, used for determining expression data types
130
132
/// when performing type coercion.
131
133
pub fn parse_physical_window_expr (
132
134
proto : & protobuf:: PhysicalWindowExprNode ,
133
135
registry : & dyn FunctionRegistry ,
134
136
input_schema : & Schema ,
135
137
) -> Result < Arc < dyn WindowExpr > > {
136
- let codec = DefaultPhysicalExtensionCodec { } ;
138
+ parse_physical_window_expr_ext (
139
+ proto,
140
+ registry,
141
+ input_schema,
142
+ & DefaultPhysicalExtensionCodec { } ,
143
+ )
144
+ }
145
+
146
+ // TODO: Make this the public function on next major release.
147
+ pub ( crate ) fn parse_physical_window_expr_ext (
148
+ proto : & protobuf:: PhysicalWindowExprNode ,
149
+ registry : & dyn FunctionRegistry ,
150
+ input_schema : & Schema ,
151
+ codec : & dyn PhysicalExtensionCodec ,
152
+ ) -> Result < Arc < dyn WindowExpr > > {
137
153
let window_node_expr =
138
- parse_physical_exprs ( & proto. args , registry, input_schema, & codec) ?;
154
+ parse_physical_exprs ( & proto. args , registry, input_schema, codec) ?;
139
155
140
156
let partition_by =
141
- parse_physical_exprs ( & proto. partition_by , registry, input_schema, & codec) ?;
157
+ parse_physical_exprs ( & proto. partition_by , registry, input_schema, codec) ?;
142
158
143
159
let order_by =
144
- parse_physical_sort_exprs ( & proto. order_by , registry, input_schema, & codec) ?;
160
+ parse_physical_sort_exprs ( & proto. order_by , registry, input_schema, codec) ?;
145
161
146
162
let window_frame = proto
147
163
. window_frame
@@ -187,9 +203,10 @@ where
187
203
/// # Arguments
188
204
///
189
205
/// * `proto` - Input proto with physical expression node
190
- /// * `registry` - A registry knows how to build logical expressions out of user-defined function' names
206
+ /// * `registry` - A registry knows how to build logical expressions out of user-defined function names
191
207
/// * `input_schema` - The Arrow schema for the input, used for determining expression data types
192
208
/// when performing type coercion.
209
+ /// * `codec` - An extension codec used to decode custom UDFs.
193
210
pub fn parse_physical_expr (
194
211
proto : & protobuf:: PhysicalExprNode ,
195
212
registry : & dyn FunctionRegistry ,
@@ -213,13 +230,15 @@ pub fn parse_physical_expr(
213
230
registry,
214
231
"left" ,
215
232
input_schema,
233
+ codec,
216
234
) ?,
217
235
logical_plan:: from_proto:: from_proto_binary_op ( & binary_expr. op ) ?,
218
236
parse_required_physical_expr (
219
237
binary_expr. r . as_deref ( ) ,
220
238
registry,
221
239
"right" ,
222
240
input_schema,
241
+ codec,
223
242
) ?,
224
243
) ) ,
225
244
ExprType :: AggregateExpr ( _) => {
@@ -241,6 +260,7 @@ pub fn parse_physical_expr(
241
260
registry,
242
261
"expr" ,
243
262
input_schema,
263
+ codec,
244
264
) ?) )
245
265
}
246
266
ExprType :: IsNotNullExpr ( e) => {
@@ -249,20 +269,23 @@ pub fn parse_physical_expr(
249
269
registry,
250
270
"expr" ,
251
271
input_schema,
272
+ codec,
252
273
) ?) )
253
274
}
254
275
ExprType :: NotExpr ( e) => Arc :: new ( NotExpr :: new ( parse_required_physical_expr (
255
276
e. expr . as_deref ( ) ,
256
277
registry,
257
278
"expr" ,
258
279
input_schema,
280
+ codec,
259
281
) ?) ) ,
260
282
ExprType :: Negative ( e) => {
261
283
Arc :: new ( NegativeExpr :: new ( parse_required_physical_expr (
262
284
e. expr . as_deref ( ) ,
263
285
registry,
264
286
"expr" ,
265
287
input_schema,
288
+ codec,
266
289
) ?) )
267
290
}
268
291
ExprType :: InList ( e) => in_list (
@@ -271,6 +294,7 @@ pub fn parse_physical_expr(
271
294
registry,
272
295
"expr" ,
273
296
input_schema,
297
+ codec,
274
298
) ?,
275
299
parse_physical_exprs ( & e. list , registry, input_schema, codec) ?,
276
300
& e. negated ,
@@ -290,12 +314,14 @@ pub fn parse_physical_expr(
290
314
registry,
291
315
"when_expr" ,
292
316
input_schema,
317
+ codec,
293
318
) ?,
294
319
parse_required_physical_expr (
295
320
e. then_expr . as_ref ( ) ,
296
321
registry,
297
322
"then_expr" ,
298
323
input_schema,
324
+ codec,
299
325
) ?,
300
326
) )
301
327
} )
@@ -311,6 +337,7 @@ pub fn parse_physical_expr(
311
337
registry,
312
338
"expr" ,
313
339
input_schema,
340
+ codec,
314
341
) ?,
315
342
convert_required ! ( e. arrow_type) ?,
316
343
None ,
@@ -321,6 +348,7 @@ pub fn parse_physical_expr(
321
348
registry,
322
349
"expr" ,
323
350
input_schema,
351
+ codec,
324
352
) ?,
325
353
convert_required ! ( e. arrow_type) ?,
326
354
) ) ,
@@ -371,12 +399,14 @@ pub fn parse_physical_expr(
371
399
registry,
372
400
"expr" ,
373
401
input_schema,
402
+ codec,
374
403
) ?,
375
404
parse_required_physical_expr (
376
405
like_expr. pattern . as_deref ( ) ,
377
406
registry,
378
407
"pattern" ,
379
408
input_schema,
409
+ codec,
380
410
) ?,
381
411
) ) ,
382
412
} ;
@@ -389,9 +419,9 @@ fn parse_required_physical_expr(
389
419
registry : & dyn FunctionRegistry ,
390
420
field : & str ,
391
421
input_schema : & Schema ,
422
+ codec : & dyn PhysicalExtensionCodec ,
392
423
) -> Result < Arc < dyn PhysicalExpr > > {
393
- let codec = DefaultPhysicalExtensionCodec { } ;
394
- expr. map ( |e| parse_physical_expr ( e, registry, input_schema, & codec) )
424
+ expr. map ( |e| parse_physical_expr ( e, registry, input_schema, codec) )
395
425
. transpose ( ) ?
396
426
. ok_or_else ( || {
397
427
DataFusionError :: Internal ( format ! ( "Missing required field {field:?}" ) )
@@ -433,15 +463,29 @@ pub fn parse_protobuf_hash_partitioning(
433
463
partitioning : Option < & protobuf:: PhysicalHashRepartition > ,
434
464
registry : & dyn FunctionRegistry ,
435
465
input_schema : & Schema ,
466
+ ) -> Result < Option < Partitioning > > {
467
+ parse_protobuf_hash_partitioning_ext (
468
+ partitioning,
469
+ registry,
470
+ input_schema,
471
+ & DefaultPhysicalExtensionCodec { } ,
472
+ )
473
+ }
474
+
475
+ // TODO: Make this the public function on next major release.
476
+ fn parse_protobuf_hash_partitioning_ext (
477
+ partitioning : Option < & protobuf:: PhysicalHashRepartition > ,
478
+ registry : & dyn FunctionRegistry ,
479
+ input_schema : & Schema ,
480
+ codec : & dyn PhysicalExtensionCodec ,
436
481
) -> Result < Option < Partitioning > > {
437
482
match partitioning {
438
483
Some ( hash_part) => {
439
- let codec = DefaultPhysicalExtensionCodec { } ;
440
484
let expr = parse_physical_exprs (
441
485
& hash_part. hash_expr ,
442
486
registry,
443
487
input_schema,
444
- & codec,
488
+ codec,
445
489
) ?;
446
490
447
491
Ok ( Some ( Partitioning :: Hash (
@@ -456,6 +500,19 @@ pub fn parse_protobuf_hash_partitioning(
456
500
pub fn parse_protobuf_file_scan_config (
457
501
proto : & protobuf:: FileScanExecConf ,
458
502
registry : & dyn FunctionRegistry ,
503
+ ) -> Result < FileScanConfig > {
504
+ parse_protobuf_file_scan_config_ext (
505
+ proto,
506
+ registry,
507
+ & DefaultPhysicalExtensionCodec { } ,
508
+ )
509
+ }
510
+
511
+ // TODO: Make this the public function on next major release.
512
+ pub ( crate ) fn parse_protobuf_file_scan_config_ext (
513
+ proto : & protobuf:: FileScanExecConf ,
514
+ registry : & dyn FunctionRegistry ,
515
+ codec : & dyn PhysicalExtensionCodec ,
459
516
) -> Result < FileScanConfig > {
460
517
let schema: Arc < Schema > = Arc :: new ( convert_required ! ( proto. schema) ?) ;
461
518
let projection = proto
@@ -489,7 +546,7 @@ pub fn parse_protobuf_file_scan_config(
489
546
. collect :: < Result < Vec < _ > > > ( ) ?;
490
547
491
548
// Remove partition columns from the schema after recreating table_partition_cols
492
- // because the partition columns are not in the file. They are present to allow the
549
+ // because the partition columns are not in the file. They are present to allow
493
550
// the partition column types to be reconstructed after serde.
494
551
let file_schema = Arc :: new ( Schema :: new (
495
552
schema
@@ -502,12 +559,11 @@ pub fn parse_protobuf_file_scan_config(
502
559
503
560
let mut output_ordering = vec ! [ ] ;
504
561
for node_collection in & proto. output_ordering {
505
- let codec = DefaultPhysicalExtensionCodec { } ;
506
562
let sort_expr = parse_physical_sort_exprs (
507
563
& node_collection. physical_sort_expr_nodes ,
508
564
registry,
509
565
& schema,
510
- & codec,
566
+ codec,
511
567
) ?;
512
568
output_ordering. push ( sort_expr) ;
513
569
}
0 commit comments