1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
use crate::config_extension_ext::{
set_distributed_option_extension, set_distributed_option_extension_from_headers,
};
use crate::distributed_planner::set_distributed_task_estimator;
use crate::networking::{set_distributed_channel_resolver, set_distributed_worker_resolver};
use crate::passthrough_headers::set_passthrough_headers;
use crate::protobuf::{set_distributed_user_codec, set_distributed_user_codec_arc};
use crate::work_unit_feed::set_distributed_work_unit_feed;
use crate::{
ChannelResolver, DistributedConfig, TaskEstimator, WorkUnitFeed, WorkUnitFeedProvider,
WorkerResolver,
};
use arrow_ipc::CompressionType;
use datafusion::common::DataFusionError;
use datafusion::config::ConfigExtension;
use datafusion::execution::{SessionState, SessionStateBuilder};
use datafusion::physical_plan::ExecutionPlan;
use datafusion::prelude::{SessionConfig, SessionContext};
use datafusion_proto::physical_plan::PhysicalExtensionCodec;
use delegate::delegate;
use http::HeaderMap;
use std::sync::Arc;
/// Extends DataFusion with distributed capabilities.
pub trait DistributedExt: Sized {
/// Adds the provided [ConfigExtension] to the distributed context. The [ConfigExtension] will
/// be serialized using gRPC metadata and sent across tasks. Users are expected to call this
/// method with their own extensions to be able to access them in any place in the
/// plan.
///
/// This method also adds the provided [ConfigExtension] to the current session option
/// extensions, the same as calling [SessionConfig::with_option_extension].
///
/// Example:
///
/// ```rust
/// # use async_trait::async_trait;
/// # use datafusion::common::{extensions_options, DataFusionError};
/// # use datafusion::config::ConfigExtension;
/// # use datafusion::execution::{SessionState, SessionStateBuilder};
/// # use datafusion::prelude::SessionConfig;
/// # use datafusion_distributed::{DistributedExt, WorkerSessionBuilder, WorkerQueryContext};
///
/// extensions_options! {
/// pub struct CustomExtension {
/// pub foo: String, default = "".to_string()
/// pub bar: usize, default = 0
/// pub baz: bool, default = false
/// }
/// }
///
/// impl ConfigExtension for CustomExtension {
/// const PREFIX: &'static str = "custom";
/// }
///
/// let mut my_custom_extension = CustomExtension::default();
/// // Now, the CustomExtension will be able to cross network boundaries. Upon making an Arrow
/// // Flight request, it will be sent through gRPC metadata.
/// let state = SessionStateBuilder::new()
/// .with_distributed_option_extension(my_custom_extension)
/// .build();
///
/// async fn build_state(ctx: WorkerQueryContext) -> Result<SessionState, DataFusionError> {
/// // This function can be provided to a Worker to tell it how to
/// // build sessions that retrieve the CustomExtension from gRPC metadata.
/// Ok(ctx
/// .builder
/// .with_distributed_option_extension_from_headers::<CustomExtension>(&ctx.headers)?
/// .build())
/// }
/// ```
fn with_distributed_option_extension<T: ConfigExtension + Default>(self, t: T) -> Self;
/// Same as [DistributedExt::with_distributed_option_extension] but with an in-place mutation
fn set_distributed_option_extension<T: ConfigExtension + Default>(&mut self, t: T);
/// Adds the provided [ConfigExtension] to the distributed context. The [ConfigExtension] will
/// be serialized using gRPC metadata and sent across tasks. Users are expected to call this
/// method with their own extensions to be able to access them in any place in the
/// plan.
///
/// - If there was a [ConfigExtension] of the same type already present, it's updated with an
/// in-place mutation based on the headers that came over the wire.
/// - If there was no [ConfigExtension] set before, it will get added, as if
/// [SessionConfig::with_option_extension] was being called.
///
/// Example:
///
/// ```rust
/// # use async_trait::async_trait;
/// # use datafusion::common::{extensions_options, DataFusionError};
/// # use datafusion::config::ConfigExtension;
/// # use datafusion::execution::{SessionState, SessionStateBuilder};
/// # use datafusion::prelude::SessionConfig;
/// # use datafusion_distributed::{DistributedExt, WorkerSessionBuilder, WorkerQueryContext};
///
/// extensions_options! {
/// pub struct CustomExtension {
/// pub foo: String, default = "".to_string()
/// pub bar: usize, default = 0
/// pub baz: bool, default = false
/// }
/// }
///
/// impl ConfigExtension for CustomExtension {
/// const PREFIX: &'static str = "custom";
/// }
///
/// let mut my_custom_extension = CustomExtension::default();
/// // Now, the CustomExtension will be able to cross network boundaries. Upon making an Arrow
/// // Flight request, it will be sent through gRPC metadata.
/// let state = SessionStateBuilder::new()
/// .with_distributed_option_extension(my_custom_extension)
/// .build();
///
/// async fn build_state(ctx: WorkerQueryContext) -> Result<SessionState, DataFusionError> {
/// // This function can be provided to a Worker to tell it how to
/// // build sessions that retrieve the CustomExtension from gRPC metadata.
/// Ok(ctx
/// .builder
/// .with_distributed_option_extension_from_headers::<CustomExtension>(&ctx.headers)?
/// .build())
/// }
/// ```
fn with_distributed_option_extension_from_headers<T: ConfigExtension + Default>(
self,
headers: &HeaderMap,
) -> Result<Self, DataFusionError>;
/// Same as [DistributedExt::with_distributed_option_extension_from_headers] but with an in-place mutation
fn set_distributed_option_extension_from_headers<T: ConfigExtension + Default>(
&mut self,
headers: &HeaderMap,
) -> Result<(), DataFusionError>;
/// Injects a user-defined [PhysicalExtensionCodec] that is capable of encoding/decoding
/// custom execution nodes. Multiple user-defined [PhysicalExtensionCodec] can be added
/// by calling this method several times.
///
/// Example:
///
/// ```
/// # use std::sync::Arc;
/// # use datafusion::common::DataFusionError;
/// # use datafusion::execution::{SessionState, FunctionRegistry, SessionStateBuilder, TaskContext};
/// # use datafusion::physical_plan::ExecutionPlan;
/// # use datafusion::prelude::SessionConfig;
/// # use datafusion_proto::physical_plan::PhysicalExtensionCodec;
/// # use datafusion_distributed::{DistributedExt, WorkerQueryContext};
///
/// #[derive(Debug)]
/// struct CustomExecCodec;
///
/// impl PhysicalExtensionCodec for CustomExecCodec {
/// fn try_decode(&self, buf: &[u8], inputs: &[Arc<dyn ExecutionPlan>], ctx: &TaskContext) -> datafusion::common::Result<Arc<dyn ExecutionPlan>> {
/// todo!()
/// }
///
/// fn try_encode(&self, node: Arc<dyn ExecutionPlan>, buf: &mut Vec<u8>) -> datafusion::common::Result<()> {
/// todo!()
/// }
/// }
///
/// let state = SessionStateBuilder::new()
/// .with_distributed_user_codec(CustomExecCodec)
/// .build();
///
/// async fn build_state(ctx: WorkerQueryContext) -> Result<SessionState, DataFusionError> {
/// // This function can be provided to a Worker to tell it how to
/// // encode/decode CustomExec nodes.
/// Ok(SessionStateBuilder::new()
/// .with_distributed_user_codec(CustomExecCodec)
/// .build())
/// }
/// ```
fn with_distributed_user_codec<T: PhysicalExtensionCodec + 'static>(self, codec: T) -> Self;
/// Same as [DistributedExt::with_distributed_user_codec] but with an in-place mutation
fn set_distributed_user_codec<T: PhysicalExtensionCodec + 'static>(&mut self, codec: T);
/// Same as [DistributedExt::with_distributed_user_codec] but with a dynamic argument.
fn with_distributed_user_codec_arc(self, codec: Arc<dyn PhysicalExtensionCodec>) -> Self;
/// Same as [DistributedExt::set_distributed_user_codec] but with a dynamic argument.
fn set_distributed_user_codec_arc(&mut self, codec: Arc<dyn PhysicalExtensionCodec>);
/// This is what tells Distributed DataFusion the URLs of the workers available for serving queries.
///
/// It injects a [WorkerResolver] implementation for Distributed DataFusion to resolve worker
/// nodes in the cluster. When running in distributed mode, setting a [WorkerResolver] is required.
///
/// Even if this is required to be present in the [SessionContext] that first initiates and
/// plans the query, it's not necessary to be present in a Worker's session state builder,
/// as no planning happens there.
///
/// Example:
///
/// ```
/// # use async_trait::async_trait;
/// # use datafusion::common::DataFusionError;
/// # use datafusion::execution::{SessionState, SessionStateBuilder};
/// # use datafusion::prelude::SessionConfig;
/// # use url::Url;
/// # use std::sync::Arc;
/// # use datafusion_distributed::{BoxCloneSyncChannel, WorkerResolver, DistributedExt, SessionStateBuilderExt, WorkerQueryContext};
///
/// struct CustomWorkerResolver;
///
/// #[async_trait]
/// impl WorkerResolver for CustomWorkerResolver {
/// fn get_urls(&self) -> Result<Vec<Url>, DataFusionError> {
/// todo!()
/// }
/// }
///
/// // This tweaks the SessionState so that it can plan for distributed queries and execute them.
/// let state = SessionStateBuilder::new()
/// .with_distributed_worker_resolver(CustomWorkerResolver)
/// .with_distributed_planner()
/// .build();
/// ```
fn with_distributed_worker_resolver<T: WorkerResolver + Send + Sync + 'static>(
self,
resolver: T,
) -> Self;
/// Same as [DistributedExt::with_distributed_channel_resolver] but with an in-place mutation.
fn set_distributed_worker_resolver<T: WorkerResolver + Send + Sync + 'static>(
&mut self,
resolver: T,
);
/// This is what tells Distributed DataFusion how to build a Worker gRPC client out of a worker URL.
///
/// There's a default implementation that caches the Worker client instances so that there's
/// only one per URL, but users can decide to override that behavior in favor of their own solution.
///
/// Example:
///
/// ```
/// # use async_trait::async_trait;
/// # use datafusion::common::DataFusionError;
/// # use datafusion::execution::{SessionState, SessionStateBuilder};
/// # use datafusion::prelude::SessionConfig;
/// # use url::Url;
/// # use std::sync::Arc;
/// # use datafusion_distributed::{BoxCloneSyncChannel, ChannelResolver, DistributedExt, SessionStateBuilderExt, WorkerQueryContext, WorkerServiceClient};
///
/// struct CustomChannelResolver;
///
/// #[async_trait]
/// impl ChannelResolver for CustomChannelResolver {
/// async fn get_worker_client_for_url(&self, url: &Url) -> Result<WorkerServiceClient<BoxCloneSyncChannel>, DataFusionError> {
/// // Build a custom WorkerServiceClient wrapped with tower layers or something similar.
/// todo!()
/// }
/// }
///
/// // This tweaks the SessionState so that it can plan for distributed queries and execute them.
/// let state = SessionStateBuilder::new()
/// .with_distributed_channel_resolver(CustomChannelResolver)
/// .with_distributed_planner()
/// .build();
///
/// // This function can be provided to a Worker so that, upon receiving a distributed
/// // part of a plan, it knows how to resolve gRPC channels from URLs for making network calls to other nodes.
/// async fn build_state(ctx: WorkerQueryContext) -> Result<SessionState, DataFusionError> {
/// // If you have a custom channel resolver, it should also be passed in the
/// // Worker session builder.
/// Ok(ctx
/// .builder
/// .with_distributed_channel_resolver(CustomChannelResolver)
/// .build())
/// }
/// ```
fn with_distributed_channel_resolver<T: ChannelResolver + Send + Sync + 'static>(
self,
resolver: T,
) -> Self;
/// Same as [DistributedExt::with_distributed_channel_resolver] but with an in-place mutation.
fn set_distributed_channel_resolver<T: ChannelResolver + Send + Sync + 'static>(
&mut self,
resolver: T,
);
/// Adds a distributed task count estimator. [TaskEstimator]s are executed on each node
/// sequentially until one returns an estimation on the number of tasks that should be
/// used for the stage containing that node.
///
/// Many nodes might decide to provide an estimation, so a reconciliation between all of them
/// is performed internally during planning.
///
/// ```text
/// ┌───────────────────────┐
/// │SortPreservingMergeExec│
/// └───────────────────────┘
/// ▲
/// ┌ ─ ─ ─ ─ ─ ─ ─ ┼ ─ ─ ─ ─ ─ ─ ─ ─ Stage 2
/// ┌───────────┴───────────┐ │
/// │ │ SortExec │
/// └───────────────────────┘ │
/// │ ┌───────────────────────┐
/// │ AggregateExec │ │
/// │ └───────────────────────┘
/// ─ ─ ─ ─ ─ ─ ─ ─▲─ ─ ─ ─ ─ ─ ─ ─ ┘
/// ┌ ─ ─ ─ ─ ─ ─ ─ ┴ ─ ─ ─ ─ ─ ─ ─ ─ Stage 1
/// ┌───────────────────────┐ │
/// │ │ FilterExec │
/// └───────────────────────┘ │
/// │ ┌───────────────────────┐ a TaskEstimator estimates the amount of tasks
/// │ SomeExec │◀───┼── based on how much data will be pulled.
/// │ └───────────────────────┘
/// ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘
/// ```
fn with_distributed_task_estimator<T: TaskEstimator + Send + Sync + 'static>(
self,
estimator: T,
) -> Self;
/// Same as [DistributedExt::with_distributed_task_estimator] but with an in-place mutation.
fn set_distributed_task_estimator<T: TaskEstimator + Send + Sync + 'static>(
&mut self,
estimator: T,
);
/// Sets the number of bytes each partition in a stage with a FileScanConfig node is
/// expected to scan. A task runs `target_partitions` partitions, so the task count is
/// roughly `total_scan_bytes / bytes_per_partition / target_partitions` (capped at the
/// number of available workers). Reducing this number increases the amount of tasks.
///
/// ```text
/// ┌───────────────────────┐
/// │SortPreservingMergeExec│
/// └───────────────────────┘
/// ▲
/// ┌ ─ ─ ─ ─ ─ ─ ─ ┼ ─ ─ ─ ─ ─ ─ ─ ─ Stage 2
/// ┌───────────┴───────────┐ │
/// │ │ SortExec │
/// └───────────────────────┘ │
/// │ ┌───────────────────────┐
/// │ AggregateExec │ │
/// │ └───────────────────────┘
/// ─ ─ ─ ─ ─ ─ ─ ─▲─ ─ ─ ─ ─ ─ ─ ─ ┘
/// ┌ ─ ─ ─ ─ ─ ─ ─ ┴ ─ ─ ─ ─ ─ ─ ─ ─ Stage 1
/// ┌───────────────────────┐ │
/// │ │ FilterExec │
/// └───────────────────────┘ │
/// │ ┌───────────────────────┐ Sets the bytes scanned per
/// │ FileScanConfig │◀───┼─ partition. Less
/// │ └───────────────────────┘ bytes_per_partition == more tasks
/// ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘
///```
fn with_distributed_file_scan_config_bytes_per_partition(
self,
bytes_per_partition: usize,
) -> Result<Self, DataFusionError>;
/// Same as [DistributedExt::with_distributed_file_scan_config_bytes_per_partition] but with an in-place mutation.
fn set_distributed_file_scan_config_bytes_per_partition(
&mut self,
bytes_per_partition: usize,
) -> Result<(), DataFusionError>;
/// The number of tasks in each stage is calculated in a bottom-to-top fashion.
///
/// Bottom stages containing leaf nodes will provide an estimation of the amount of tasks
/// for those stages, but upper stages might see a reduction (or increment) in the amount
/// of tasks based on the cardinality effect bottom stages have in the data.
///
/// For example: If there are two stages, and the leaf stage is estimated to use 10 tasks,
/// the upper stage might use less (e.g. 5) if it sees that the leaf stage is returning
/// less data because of filters or aggregations.
///
/// This function sets the scale factor for when encountering these nodes that change the
/// cardinality of the data. For example, if a stage with 10 tasks contains an AggregateExec
/// node, and the scale factor is 2.0, the following stage will use 10 / 2.0 = 5 tasks.
///
/// ```text
/// ┌───────────────────────┐
/// │SortPreservingMergeExec│
/// └───────────────────────┘
/// ▲
/// ┌ ─ ─ ─ ─ ─ ─ ─ ┼ ─ ─ ─ ─ ─ ─ ─ ─ Stage 2 (N/scale_factor tasks)
/// ┌───────────┴───────────┐ │
/// │ │ SortExec │
/// └───────────────────────┘ │
/// │ ┌───────────────────────┐
/// │ AggregateExec │ │
/// │ └───────────────────────┘
/// ─ ─ ─ ─ ─ ─ ─ ─▲─ ─ ─ ─ ─ ─ ─ ─ ┘
/// ┌ ─ ─ ─ ─ ─ ─ ─ ┴ ─ ─ ─ ─ ─ ─ ─ ─ Stage 1 (N tasks)
/// ┌───────────────────────┐ │ A filter reduces cardinality,
/// │ │ FilterExec │◀────────therefore the next stage will have
/// └───────────────────────┘ │ less tasks according to this factor
/// │ ┌───────────────────────┐
/// │ FileScanConfig │ │
/// │ └───────────────────────┘
/// ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘
/// ```
fn with_distributed_cardinality_effect_task_scale_factor(
self,
factor: f64,
) -> Result<Self, DataFusionError>;
/// Same as [DistributedExt::with_distributed_cardinality_effect_task_scale_factor] but with
/// an in-place mutation.
fn set_distributed_cardinality_effect_task_scale_factor(
&mut self,
factor: f64,
) -> Result<(), DataFusionError>;
/// Enables metrics collection across network boundaries so that all the metrics gather in
/// each node are accessible from the head stage that started running the query.
fn with_distributed_metrics_collection(self, enabled: bool) -> Result<Self, DataFusionError>;
/// Same as [DistributedExt::with_distributed_metrics_collection] but with an in-place mutation.
fn set_distributed_metrics_collection(&mut self, enabled: bool) -> Result<(), DataFusionError>;
/// Enables children isolator unions for distributing UNION operations across as many tasks as
/// the sum of all the tasks required for each child.
///
/// For example, if there is a UNION with 3 children, requiring one task each, it will result
/// in a plan with 3 tasks where each task runs one child:
///
/// ```text
/// ┌─────────────────────────────┐┌─────────────────────────────┐┌─────────────────────────────┐
/// │ Task 1 ││ Task 2 ││ Task 3 │
/// │┌───────────────────────────┐││┌───────────────────────────┐││┌───────────────────────────┐│
/// ││ ChildrenIsolatorUnionExec ││││ ChildrenIsolatorUnionExec ││││ ChildrenIsolatorUnionExec ││
/// │└───▲─────────▲─────────▲───┘││└───▲─────────▲─────────▲───┘││└───▲─────────▲─────────▲───┘│
/// │ │ ││ │ ││ │ │
/// │┌───┴───┐ ┌ ─│ ─ ┌ ─│ ─ ││┌ ─│ ─ ┌───┴───┐ ┌ ─│ ─ ││┌ ─│ ─ ┌ ─│ ─ ┌───┴───┐│
/// ││Child 1│ Child 2│ Child 3│││ Child 1│ │Child 2│ Child 3│││ Child 1│ Child 2│ │Child 3││
/// │└───────┘ └ ─ ─ └ ─ ─ ││└ ─ ─ └───────┘ └ ─ ─ ││└ ─ ─ └ ─ ─ └───────┘│
/// └─────────────────────────────┘└─────────────────────────────┘└─────────────────────────────┘
/// ```
fn with_distributed_children_isolator_unions(
self,
enabled: bool,
) -> Result<Self, DataFusionError>;
/// Same as [DistributedExt::with_distributed_children_isolator_unions] but with an in-place mutation.
fn set_distributed_children_isolator_unions(
&mut self,
enabled: bool,
) -> Result<(), DataFusionError>;
/// Enables broadcast joins for CollectLeft hash joins. When enabled, the build side of
/// a CollectLeft join is broadcast to all consumer tasks instead of being coalesced
/// into a single partition.
///
/// Note: This option is disabled by default until the implementation is smarter about when to
/// broadcast.
fn with_distributed_broadcast_joins(self, enabled: bool) -> Result<Self, DataFusionError>;
/// Same as [DistributedExt::with_distributed_broadcast_joins_enabled] but with an in-place mutation.
fn set_distributed_broadcast_joins(&mut self, enabled: bool) -> Result<(), DataFusionError>;
/// The compression type to use for sending data over the wire.
///
/// The default is [CompressionType::LZ4_FRAME].
fn with_distributed_compression(
self,
compression: Option<CompressionType>,
) -> Result<Self, DataFusionError>;
/// Same as [DistributedExt::with_distributed_compression] but with an in-place mutation.
fn set_distributed_compression(
&mut self,
compression: Option<CompressionType>,
) -> Result<(), DataFusionError>;
/// Overrides `datafusion.execution.batch_size` for worker-executed stages, letting users
/// tune shuffle batch sizes (specifically `RepartitionExec`'s output batching via its
/// internal `LimitedBatchCoalescer`) independently of the global batch size.
///
/// Set to 0 (the default) to apply no override.
fn with_distributed_shuffle_batch_size(
self,
batch_size: usize,
) -> Result<Self, DataFusionError>;
/// Same as [DistributedExt::with_distributed_shuffle_batch_size] but with an in-place mutation.
fn set_distributed_shuffle_batch_size(
&mut self,
batch_size: usize,
) -> Result<(), DataFusionError>;
/// Sets arbitrary HTTP headers that will be forwarded unchanged to worker nodes.
/// These headers are included in outgoing Arrow Flight requests to workers.
///
/// Returns an error if any header name starts with the reserved prefix
/// `x-datafusion-distributed-config-`, which is used internally.
///
/// Example:
///
/// ```rust
/// # use datafusion::execution::SessionStateBuilder;
/// # use datafusion_distributed::DistributedExt;
/// # use http::HeaderMap;
///
/// let mut passthrough = HeaderMap::new();
/// passthrough.insert("x-custom-priority", "high".parse().unwrap());
///
/// let state = SessionStateBuilder::new()
/// .with_distributed_passthrough_headers(passthrough)
/// .unwrap()
/// .build();
/// ```
fn with_distributed_passthrough_headers(
self,
headers: HeaderMap,
) -> Result<Self, DataFusionError>;
/// Same as [DistributedExt::with_distributed_passthrough_headers] but with an in-place mutation.
fn set_distributed_passthrough_headers(
&mut self,
headers: HeaderMap,
) -> Result<(), DataFusionError>;
/// Sets the maximum tasks that will be assigned for each stage.
///
/// If not specified, the number of workers returned by the provided [WorkerResolver] is taken.
fn with_distributed_max_tasks_per_stage(
self,
max_tasks_per_stage: usize,
) -> Result<Self, DataFusionError>;
/// Same as [DistributedExt::with_distributed_max_tasks_per_stage] but with an in-place mutation.
fn set_distributed_max_tasks_per_stage(
&mut self,
max_tasks_per_stage: usize,
) -> Result<(), DataFusionError>;
/// Enables or disables the PartialReduce optimization, which inserts an extra aggregation
/// pass above hash RepartitionExec before network shuffles to reduce shuffle data size.
/// Disabled by default because its effectiveness is workload-dependent: it helps when
/// aggregation significantly reduces cardinality, but adds overhead when it does not.
fn with_distributed_partial_reduce(self, enabled: bool) -> Result<Self, DataFusionError>;
/// Same as [DistributedExt::with_distributed_partial_reduce] but with an in-place mutation.
fn set_distributed_partial_reduce(&mut self, enabled: bool) -> Result<(), DataFusionError>;
/// Sets the soft byte budget that each per-worker connection will buffer in memory before
/// pausing the gRPC pull from that worker. Per-partition channels are unbounded (to avoid
/// head-of-line blocking between sibling partitions), so backpressure is enforced globally
/// per worker connection using this budget.
fn with_distributed_worker_connection_buffer_budget_bytes(
self,
budget_bytes: usize,
) -> Result<Self, DataFusionError>;
/// Same as [DistributedExt::with_distributed_worker_connection_buffer_budget_bytes] but with
/// an in-place mutation.
fn set_distributed_worker_connection_buffer_budget_bytes(
&mut self,
budget_bytes: usize,
) -> Result<(), DataFusionError>;
/// Registers a [WorkUnitFeed] so that Distributed DataFusion can discover it while traversing
/// plans. For more info, refer to [WorkUnitFeed] docs.
///
/// This method uses some type system trickery so that users can provide a callback like this:
///
/// ```ignore
/// # use datafusion::execution::SessionStateBuilder;
///
/// SessionStateBuilder::new()
/// .with_distributed_work_unit_feed(|p: &MyCustomPlan| &p.my_work_unit_feed);
/// ```
fn with_distributed_work_unit_feed<T, P, F>(self, getter: F) -> Self
where
T: ExecutionPlan + 'static,
P: WorkUnitFeedProvider + 'static,
P::WorkUnit: 'static,
F: Fn(&T) -> Option<&WorkUnitFeed<P>> + Send + Sync + 'static;
/// Same as [DistributedExt::with_distributed_work_unit_feed] but with an in-place mutation.
fn set_distributed_work_unit_feed<T, P, F>(&mut self, getter: F)
where
T: ExecutionPlan + 'static,
P: WorkUnitFeedProvider + 'static,
P::WorkUnit: 'static,
F: Fn(&T) -> Option<&WorkUnitFeed<P>> + Send + Sync + 'static;
}
impl DistributedExt for SessionConfig {
fn set_distributed_option_extension<T: ConfigExtension + Default>(&mut self, t: T) {
set_distributed_option_extension(self, t)
}
fn set_distributed_option_extension_from_headers<T: ConfigExtension + Default>(
&mut self,
headers: &HeaderMap,
) -> Result<(), DataFusionError> {
set_distributed_option_extension_from_headers::<T>(self, headers)?;
Ok(())
}
fn set_distributed_user_codec<T: PhysicalExtensionCodec + 'static>(&mut self, codec: T) {
set_distributed_user_codec(self, codec)
}
fn set_distributed_user_codec_arc(&mut self, codec: Arc<dyn PhysicalExtensionCodec>) {
set_distributed_user_codec_arc(self, codec)
}
fn set_distributed_worker_resolver<T: WorkerResolver + Send + Sync + 'static>(
&mut self,
resolver: T,
) {
set_distributed_worker_resolver(self, resolver);
}
fn set_distributed_channel_resolver<T: ChannelResolver + Send + Sync + 'static>(
&mut self,
resolver: T,
) {
set_distributed_channel_resolver(self, resolver);
}
fn set_distributed_task_estimator<T: TaskEstimator + Send + Sync + 'static>(
&mut self,
estimator: T,
) {
set_distributed_task_estimator(self, estimator)
}
fn set_distributed_file_scan_config_bytes_per_partition(
&mut self,
bytes_per_partition: usize,
) -> Result<(), DataFusionError> {
let d_cfg = DistributedConfig::from_config_options_mut(self.options_mut())?;
d_cfg.file_scan_config_bytes_per_partition = bytes_per_partition;
Ok(())
}
fn set_distributed_cardinality_effect_task_scale_factor(
&mut self,
factor: f64,
) -> Result<(), DataFusionError> {
let d_cfg = DistributedConfig::from_config_options_mut(self.options_mut())?;
d_cfg.cardinality_task_count_factor = factor;
Ok(())
}
fn set_distributed_metrics_collection(&mut self, enabled: bool) -> Result<(), DataFusionError> {
let d_cfg = DistributedConfig::from_config_options_mut(self.options_mut())?;
d_cfg.collect_metrics = enabled;
Ok(())
}
fn set_distributed_children_isolator_unions(
&mut self,
enabled: bool,
) -> Result<(), DataFusionError> {
let d_cfg = DistributedConfig::from_config_options_mut(self.options_mut())?;
d_cfg.children_isolator_unions = enabled;
Ok(())
}
fn set_distributed_broadcast_joins(&mut self, enabled: bool) -> Result<(), DataFusionError> {
let d_cfg = DistributedConfig::from_config_options_mut(self.options_mut())?;
d_cfg.broadcast_joins = enabled;
Ok(())
}
fn set_distributed_compression(
&mut self,
compression: Option<CompressionType>,
) -> Result<(), DataFusionError> {
let d_cfg = DistributedConfig::from_config_options_mut(self.options_mut())?;
d_cfg.compression = match compression {
Some(CompressionType::ZSTD) => "zstd".to_string(),
Some(CompressionType::LZ4_FRAME) => "lz4".to_string(),
_ => "none".to_string(),
};
Ok(())
}
fn set_distributed_shuffle_batch_size(
&mut self,
batch_size: usize,
) -> Result<(), DataFusionError> {
let d_cfg = DistributedConfig::from_config_options_mut(self.options_mut())?;
d_cfg.shuffle_batch_size = batch_size;
Ok(())
}
fn set_distributed_passthrough_headers(
&mut self,
headers: HeaderMap,
) -> Result<(), DataFusionError> {
set_passthrough_headers(self, headers)
}
fn set_distributed_max_tasks_per_stage(
&mut self,
max_tasks_per_stage: usize,
) -> Result<(), DataFusionError> {
let d_cfg = DistributedConfig::from_config_options_mut(self.options_mut())?;
d_cfg.max_tasks_per_stage = max_tasks_per_stage;
Ok(())
}
fn set_distributed_partial_reduce(&mut self, enabled: bool) -> Result<(), DataFusionError> {
let d_cfg = DistributedConfig::from_config_options_mut(self.options_mut())?;
d_cfg.partial_reduce = enabled;
Ok(())
}
fn set_distributed_worker_connection_buffer_budget_bytes(
&mut self,
budget_bytes: usize,
) -> Result<(), DataFusionError> {
let d_cfg = DistributedConfig::from_config_options_mut(self.options_mut())?;
d_cfg.worker_connection_buffer_budget_bytes = budget_bytes;
Ok(())
}
fn set_distributed_work_unit_feed<T, P, F>(&mut self, getter: F)
where
T: ExecutionPlan + 'static,
P: WorkUnitFeedProvider + 'static,
P::WorkUnit: 'static,
F: Fn(&T) -> Option<&WorkUnitFeed<P>> + Send + Sync + 'static,
{
set_distributed_work_unit_feed(self, move |plan: &Arc<dyn ExecutionPlan>| {
plan.downcast_ref::<T>().and_then(&getter)
})
}
delegate! {
to self {
#[call(set_distributed_option_extension)]
#[expr($;self)]
fn with_distributed_option_extension<T: ConfigExtension + Default>(mut self, t: T) -> Self;
#[call(set_distributed_option_extension_from_headers)]
#[expr($?;Ok(self))]
fn with_distributed_option_extension_from_headers<T: ConfigExtension + Default>(mut self, headers: &HeaderMap) -> Result<Self, DataFusionError>;
#[call(set_distributed_user_codec)]
#[expr($;self)]
fn with_distributed_user_codec<T: PhysicalExtensionCodec + 'static>(mut self, codec: T) -> Self;
#[call(set_distributed_user_codec_arc)]
#[expr($;self)]
fn with_distributed_user_codec_arc(mut self, codec: Arc<dyn PhysicalExtensionCodec>) -> Self;
#[call(set_distributed_worker_resolver)]
#[expr($;self)]
fn with_distributed_worker_resolver<T: WorkerResolver + Send + Sync + 'static>(mut self, resolver: T) -> Self;
#[call(set_distributed_channel_resolver)]
#[expr($;self)]
fn with_distributed_channel_resolver<T: ChannelResolver + Send + Sync + 'static>(mut self, resolver: T) -> Self;
#[call(set_distributed_task_estimator)]
#[expr($;self)]
fn with_distributed_task_estimator<T: TaskEstimator + Send + Sync + 'static>(mut self, estimator: T) -> Self;
#[call(set_distributed_file_scan_config_bytes_per_partition)]
#[expr($?;Ok(self))]
fn with_distributed_file_scan_config_bytes_per_partition(mut self, bytes_per_partition: usize) -> Result<Self, DataFusionError>;
#[call(set_distributed_cardinality_effect_task_scale_factor)]
#[expr($?;Ok(self))]
fn with_distributed_cardinality_effect_task_scale_factor(mut self, factor: f64) -> Result<Self, DataFusionError>;
#[call(set_distributed_metrics_collection)]
#[expr($?;Ok(self))]
fn with_distributed_metrics_collection(mut self, enabled: bool) -> Result<Self, DataFusionError>;
#[call(set_distributed_children_isolator_unions)]
#[expr($?;Ok(self))]
fn with_distributed_children_isolator_unions(mut self, enabled: bool) -> Result<Self, DataFusionError>;
#[call(set_distributed_broadcast_joins)]
#[expr($?;Ok(self))]
fn with_distributed_broadcast_joins(mut self, enabled: bool) -> Result<Self, DataFusionError>;
#[call(set_distributed_compression)]
#[expr($?;Ok(self))]
fn with_distributed_compression(mut self, compression: Option<CompressionType>) -> Result<Self, DataFusionError>;
#[call(set_distributed_shuffle_batch_size)]
#[expr($?;Ok(self))]
fn with_distributed_shuffle_batch_size(mut self, batch_size: usize) -> Result<Self, DataFusionError>;
#[call(set_distributed_passthrough_headers)]
#[expr($?;Ok(self))]
fn with_distributed_passthrough_headers(mut self, headers: HeaderMap) -> Result<Self, DataFusionError>;
#[call(set_distributed_max_tasks_per_stage)]
#[expr($?;Ok(self))]
fn with_distributed_max_tasks_per_stage(mut self, max_tasks_per_stage: usize) -> Result<Self, DataFusionError>;
#[call(set_distributed_partial_reduce)]
#[expr($?;Ok(self))]
fn with_distributed_partial_reduce(mut self, enabled: bool) -> Result<Self, DataFusionError>;
#[call(set_distributed_worker_connection_buffer_budget_bytes)]
#[expr($?;Ok(self))]
fn with_distributed_worker_connection_buffer_budget_bytes(mut self, budget_bytes: usize) -> Result<Self, DataFusionError>;
#[call(set_distributed_work_unit_feed)]
#[expr($;self)]
fn with_distributed_work_unit_feed<T, P, F>(mut self, getter: F) -> Self
where
T: ExecutionPlan + 'static,
P: WorkUnitFeedProvider + 'static,
P::WorkUnit: 'static,
F: Fn(&T) -> Option<&WorkUnitFeed<P>> + Send + Sync + 'static;
}
}
}
impl DistributedExt for SessionStateBuilder {
delegate! {
to self.config().get_or_insert_default() {
fn set_distributed_option_extension<T: ConfigExtension + Default>(&mut self, t: T);
#[call(set_distributed_option_extension)]
#[expr($;self)]
fn with_distributed_option_extension<T: ConfigExtension + Default>(mut self, t: T) -> Self;
fn set_distributed_option_extension_from_headers<T: ConfigExtension + Default>(&mut self, h: &HeaderMap) -> Result<(), DataFusionError>;
#[call(set_distributed_option_extension_from_headers)]
#[expr($?;Ok(self))]
fn with_distributed_option_extension_from_headers<T: ConfigExtension + Default>(mut self, headers: &HeaderMap) -> Result<Self, DataFusionError>;
fn set_distributed_user_codec<T: PhysicalExtensionCodec + 'static>(&mut self, codec: T);
#[call(set_distributed_user_codec)]
#[expr($;self)]
fn with_distributed_user_codec<T: PhysicalExtensionCodec + 'static>(mut self, codec: T) -> Self;
fn set_distributed_user_codec_arc(&mut self, codec: Arc<dyn PhysicalExtensionCodec>);
#[call(set_distributed_user_codec_arc)]
#[expr($;self)]
fn with_distributed_user_codec_arc(mut self, codec: Arc<dyn PhysicalExtensionCodec>) -> Self;
fn set_distributed_worker_resolver<T: WorkerResolver + Send + Sync + 'static>(&mut self, resolver: T);
#[call(set_distributed_worker_resolver)]
#[expr($;self)]
fn with_distributed_worker_resolver<T: WorkerResolver + Send + Sync + 'static>(mut self, resolver: T) -> Self;
fn set_distributed_channel_resolver<T: ChannelResolver + Send + Sync + 'static>(&mut self, resolver: T);
#[call(set_distributed_channel_resolver)]
#[expr($;self)]
fn with_distributed_channel_resolver<T: ChannelResolver + Send + Sync + 'static>(mut self, resolver: T) -> Self;
fn set_distributed_task_estimator<T: TaskEstimator + Send + Sync + 'static>(&mut self, estimator: T);
#[call(set_distributed_task_estimator)]
#[expr($;self)]
fn with_distributed_task_estimator<T: TaskEstimator + Send + Sync + 'static>(mut self, estimator: T) -> Self;
fn set_distributed_file_scan_config_bytes_per_partition(&mut self, bytes_per_partition: usize) -> Result<(), DataFusionError>;
#[call(set_distributed_file_scan_config_bytes_per_partition)]
#[expr($?;Ok(self))]
fn with_distributed_file_scan_config_bytes_per_partition(mut self, bytes_per_partition: usize) -> Result<Self, DataFusionError>;
fn set_distributed_cardinality_effect_task_scale_factor(&mut self, factor: f64) -> Result<(), DataFusionError>;
#[call(set_distributed_cardinality_effect_task_scale_factor)]
#[expr($?;Ok(self))]
fn with_distributed_cardinality_effect_task_scale_factor(mut self, factor: f64) -> Result<Self, DataFusionError>;
fn set_distributed_metrics_collection(&mut self, enabled: bool) -> Result<(), DataFusionError>;
#[call(set_distributed_metrics_collection)]
#[expr($?;Ok(self))]
fn with_distributed_metrics_collection(mut self, enabled: bool) -> Result<Self, DataFusionError>;
fn set_distributed_children_isolator_unions(&mut self, enabled: bool) -> Result<(), DataFusionError>;
#[call(set_distributed_children_isolator_unions)]
#[expr($?;Ok(self))]
fn with_distributed_children_isolator_unions(mut self, enabled: bool) -> Result<Self, DataFusionError>;
fn set_distributed_broadcast_joins(&mut self, enabled: bool) -> Result<(), DataFusionError>;
#[call(set_distributed_broadcast_joins)]
#[expr($?;Ok(self))]
fn with_distributed_broadcast_joins(mut self, enabled: bool) -> Result<Self, DataFusionError>;
fn set_distributed_compression(&mut self, compression: Option<CompressionType>) -> Result<(), DataFusionError>;
#[call(set_distributed_compression)]
#[expr($?;Ok(self))]
fn with_distributed_compression(mut self, compression: Option<CompressionType>) -> Result<Self, DataFusionError>;
fn set_distributed_shuffle_batch_size(&mut self, batch_size: usize) -> Result<(), DataFusionError>;
#[call(set_distributed_shuffle_batch_size)]
#[expr($?;Ok(self))]
fn with_distributed_shuffle_batch_size(mut self, batch_size: usize) -> Result<Self, DataFusionError>;
fn set_distributed_passthrough_headers(&mut self, headers: HeaderMap) -> Result<(), DataFusionError>;
#[call(set_distributed_passthrough_headers)]
#[expr($?;Ok(self))]
fn with_distributed_passthrough_headers(mut self, headers: HeaderMap) -> Result<Self, DataFusionError>;
fn set_distributed_max_tasks_per_stage(&mut self, max_tasks_per_stage: usize) -> Result<(), DataFusionError>;
#[call(set_distributed_max_tasks_per_stage)]
#[expr($?;Ok(self))]
fn with_distributed_max_tasks_per_stage(mut self, max_tasks_per_stage: usize) -> Result<Self, DataFusionError>;
fn set_distributed_partial_reduce(&mut self, enabled: bool) -> Result<(), DataFusionError>;
#[call(set_distributed_partial_reduce)]
#[expr($?;Ok(self))]
fn with_distributed_partial_reduce(mut self, enabled: bool) -> Result<Self, DataFusionError>;
fn set_distributed_worker_connection_buffer_budget_bytes(&mut self, budget_bytes: usize) -> Result<(), DataFusionError>;
#[call(set_distributed_worker_connection_buffer_budget_bytes)]
#[expr($?;Ok(self))]
fn with_distributed_worker_connection_buffer_budget_bytes(mut self, budget_bytes: usize) -> Result<Self, DataFusionError>;
fn set_distributed_work_unit_feed<T, P, F>(&mut self, getter: F)
where
T: ExecutionPlan + 'static,
P: WorkUnitFeedProvider + 'static,
P::WorkUnit: 'static,
F: Fn(&T) -> Option<&WorkUnitFeed<P>> + Send + Sync + 'static;
#[call(set_distributed_work_unit_feed)]
#[expr($;self)]
fn with_distributed_work_unit_feed<T, P, F>(mut self, getter: F) -> Self
where
T: ExecutionPlan + 'static,
P: WorkUnitFeedProvider + 'static,
P::WorkUnit: 'static,
F: Fn(&T) -> Option<&WorkUnitFeed<P>> + Send + Sync + 'static;
}
}
}
impl DistributedExt for SessionState {
delegate! {
to self.config_mut() {
fn set_distributed_option_extension<T: ConfigExtension + Default>(&mut self, t: T);
#[call(set_distributed_option_extension)]
#[expr($;self)]
fn with_distributed_option_extension<T: ConfigExtension + Default>(mut self, t: T) -> Self;
fn set_distributed_option_extension_from_headers<T: ConfigExtension + Default>(&mut self, h: &HeaderMap) -> Result<(), DataFusionError>;
#[call(set_distributed_option_extension_from_headers)]
#[expr($?;Ok(self))]
fn with_distributed_option_extension_from_headers<T: ConfigExtension + Default>(mut self, headers: &HeaderMap) -> Result<Self, DataFusionError>;
fn set_distributed_user_codec<T: PhysicalExtensionCodec + 'static>(&mut self, codec: T);
#[call(set_distributed_user_codec)]
#[expr($;self)]
fn with_distributed_user_codec<T: PhysicalExtensionCodec + 'static>(mut self, codec: T) -> Self;
fn set_distributed_user_codec_arc(&mut self, codec: Arc<dyn PhysicalExtensionCodec>);
#[call(set_distributed_user_codec_arc)]
#[expr($;self)]
fn with_distributed_user_codec_arc(mut self, codec: Arc<dyn PhysicalExtensionCodec>) -> Self;
fn set_distributed_worker_resolver<T: WorkerResolver + Send + Sync + 'static>(&mut self, resolver: T);
#[call(set_distributed_worker_resolver)]
#[expr($;self)]
fn with_distributed_worker_resolver<T: WorkerResolver + Send + Sync + 'static>(mut self, resolver: T) -> Self;
fn set_distributed_channel_resolver<T: ChannelResolver + Send + Sync + 'static>(&mut self, resolver: T);
#[call(set_distributed_channel_resolver)]
#[expr($;self)]
fn with_distributed_channel_resolver<T: ChannelResolver + Send + Sync + 'static>(mut self, resolver: T) -> Self;
fn set_distributed_task_estimator<T: TaskEstimator + Send + Sync + 'static>(&mut self, estimator: T);
#[call(set_distributed_task_estimator)]
#[expr($;self)]
fn with_distributed_task_estimator<T: TaskEstimator + Send + Sync + 'static>(mut self, estimator: T) -> Self;
fn set_distributed_file_scan_config_bytes_per_partition(&mut self, bytes_per_partition: usize) -> Result<(), DataFusionError>;
#[call(set_distributed_file_scan_config_bytes_per_partition)]
#[expr($?;Ok(self))]
fn with_distributed_file_scan_config_bytes_per_partition(mut self, bytes_per_partition: usize) -> Result<Self, DataFusionError>;
fn set_distributed_cardinality_effect_task_scale_factor(&mut self, factor: f64) -> Result<(), DataFusionError>;
#[call(set_distributed_cardinality_effect_task_scale_factor)]
#[expr($?;Ok(self))]
fn with_distributed_cardinality_effect_task_scale_factor(mut self, factor: f64) -> Result<Self, DataFusionError>;
fn set_distributed_metrics_collection(&mut self, enabled: bool) -> Result<(), DataFusionError>;
#[call(set_distributed_metrics_collection)]
#[expr($?;Ok(self))]
fn with_distributed_metrics_collection(mut self, enabled: bool) -> Result<Self, DataFusionError>;
fn set_distributed_children_isolator_unions(&mut self, enabled: bool) -> Result<(), DataFusionError>;
#[call(set_distributed_children_isolator_unions)]
#[expr($?;Ok(self))]
fn with_distributed_children_isolator_unions(mut self, enabled: bool) -> Result<Self, DataFusionError>;
fn set_distributed_broadcast_joins(&mut self, enabled: bool) -> Result<(), DataFusionError>;
#[call(set_distributed_broadcast_joins)]
#[expr($?;Ok(self))]
fn with_distributed_broadcast_joins(mut self, enabled: bool) -> Result<Self, DataFusionError>;
fn set_distributed_compression(&mut self, compression: Option<CompressionType>) -> Result<(), DataFusionError>;
#[call(set_distributed_compression)]
#[expr($?;Ok(self))]
fn with_distributed_compression(mut self, compression: Option<CompressionType>) -> Result<Self, DataFusionError>;
fn set_distributed_shuffle_batch_size(&mut self, batch_size: usize) -> Result<(), DataFusionError>;
#[call(set_distributed_shuffle_batch_size)]
#[expr($?;Ok(self))]
fn with_distributed_shuffle_batch_size(mut self, batch_size: usize) -> Result<Self, DataFusionError>;
fn set_distributed_passthrough_headers(&mut self, headers: HeaderMap) -> Result<(), DataFusionError>;
#[call(set_distributed_passthrough_headers)]
#[expr($?;Ok(self))]
fn with_distributed_passthrough_headers(mut self, headers: HeaderMap) -> Result<Self, DataFusionError>;
fn set_distributed_max_tasks_per_stage(&mut self, max_tasks_per_stage: usize) -> Result<(), DataFusionError>;
#[call(set_distributed_max_tasks_per_stage)]
#[expr($?;Ok(self))]
fn with_distributed_max_tasks_per_stage(mut self, max_tasks_per_stage: usize) -> Result<Self, DataFusionError>;
fn set_distributed_partial_reduce(&mut self, enabled: bool) -> Result<(), DataFusionError>;
#[call(set_distributed_partial_reduce)]
#[expr($?;Ok(self))]
fn with_distributed_partial_reduce(mut self, enabled: bool) -> Result<Self, DataFusionError>;
fn set_distributed_worker_connection_buffer_budget_bytes(&mut self, budget_bytes: usize) -> Result<(), DataFusionError>;
#[call(set_distributed_worker_connection_buffer_budget_bytes)]
#[expr($?;Ok(self))]
fn with_distributed_worker_connection_buffer_budget_bytes(mut self, budget_bytes: usize) -> Result<Self, DataFusionError>;
fn set_distributed_work_unit_feed<T, P, F>(&mut self, getter: F)
where
T: ExecutionPlan + 'static,
P: WorkUnitFeedProvider + 'static,
P::WorkUnit: 'static,
F: Fn(&T) -> Option<&WorkUnitFeed<P>> + Send + Sync + 'static;
#[call(set_distributed_work_unit_feed)]
#[expr($;self)]
fn with_distributed_work_unit_feed<T, P, F>(mut self, getter: F) -> Self
where
T: ExecutionPlan + 'static,
P: WorkUnitFeedProvider + 'static,
P::WorkUnit: 'static,
F: Fn(&T) -> Option<&WorkUnitFeed<P>> + Send + Sync + 'static;
}
}
}
impl DistributedExt for SessionContext {
delegate! {
to self.state_ref().write().config_mut() {
fn set_distributed_option_extension<T: ConfigExtension + Default>(&mut self, t: T);
#[call(set_distributed_option_extension)]
#[expr($;self)]
fn with_distributed_option_extension<T: ConfigExtension + Default>(self, t: T) -> Self;
fn set_distributed_option_extension_from_headers<T: ConfigExtension + Default>(&mut self, h: &HeaderMap) -> Result<(), DataFusionError>;
#[call(set_distributed_option_extension_from_headers)]
#[expr($?;Ok(self))]
fn with_distributed_option_extension_from_headers<T: ConfigExtension + Default>(self, headers: &HeaderMap) -> Result<Self, DataFusionError>;
fn set_distributed_user_codec<T: PhysicalExtensionCodec + 'static>(&mut self, codec: T);
#[call(set_distributed_user_codec)]
#[expr($;self)]
fn with_distributed_user_codec<T: PhysicalExtensionCodec + 'static>(self, codec: T) -> Self;
fn set_distributed_user_codec_arc(&mut self, codec: Arc<dyn PhysicalExtensionCodec>);
#[call(set_distributed_user_codec_arc)]
#[expr($;self)]
fn with_distributed_user_codec_arc(self, codec: Arc<dyn PhysicalExtensionCodec>) -> Self;
fn set_distributed_worker_resolver<T: WorkerResolver + Send + Sync + 'static>(&mut self, resolver: T);
#[call(set_distributed_worker_resolver)]
#[expr($;self)]
fn with_distributed_worker_resolver<T: WorkerResolver + Send + Sync + 'static>(self, resolver: T) -> Self;
fn set_distributed_channel_resolver<T: ChannelResolver + Send + Sync + 'static>(&mut self, resolver: T);
#[call(set_distributed_channel_resolver)]
#[expr($;self)]
fn with_distributed_channel_resolver<T: ChannelResolver + Send + Sync + 'static>(self, resolver: T) -> Self;
fn set_distributed_task_estimator<T: TaskEstimator + Send + Sync + 'static>(&mut self, estimator: T);
#[call(set_distributed_task_estimator)]
#[expr($;self)]
fn with_distributed_task_estimator<T: TaskEstimator + Send + Sync + 'static>(self, estimator: T) -> Self;
fn set_distributed_file_scan_config_bytes_per_partition(&mut self, bytes_per_partition: usize) -> Result<(), DataFusionError>;
#[call(set_distributed_file_scan_config_bytes_per_partition)]
#[expr($?;Ok(self))]
fn with_distributed_file_scan_config_bytes_per_partition(self, bytes_per_partition: usize) -> Result<Self, DataFusionError>;
fn set_distributed_cardinality_effect_task_scale_factor(&mut self, factor: f64) -> Result<(), DataFusionError>;
#[call(set_distributed_cardinality_effect_task_scale_factor)]
#[expr($?;Ok(self))]
fn with_distributed_cardinality_effect_task_scale_factor(self, factor: f64) -> Result<Self, DataFusionError>;
fn set_distributed_metrics_collection(&mut self, enabled: bool) -> Result<(), DataFusionError>;
#[call(set_distributed_metrics_collection)]
#[expr($?;Ok(self))]
fn with_distributed_metrics_collection(self, enabled: bool) -> Result<Self, DataFusionError>;
fn set_distributed_children_isolator_unions(&mut self, enabled: bool) -> Result<(), DataFusionError>;
#[call(set_distributed_children_isolator_unions)]
#[expr($?;Ok(self))]
fn with_distributed_children_isolator_unions(self, enabled: bool) -> Result<Self, DataFusionError>;
fn set_distributed_broadcast_joins(&mut self, enabled: bool) -> Result<(), DataFusionError>;
#[call(set_distributed_broadcast_joins)]
#[expr($?;Ok(self))]
fn with_distributed_broadcast_joins(self, enabled: bool) -> Result<Self, DataFusionError>;
fn set_distributed_compression(&mut self, compression: Option<CompressionType>) -> Result<(), DataFusionError>;
#[call(set_distributed_compression)]
#[expr($?;Ok(self))]
fn with_distributed_compression(self, compression: Option<CompressionType>) -> Result<Self, DataFusionError>;
fn set_distributed_shuffle_batch_size(&mut self, batch_size: usize) -> Result<(), DataFusionError>;
#[call(set_distributed_shuffle_batch_size)]
#[expr($?;Ok(self))]
fn with_distributed_shuffle_batch_size(self, batch_size: usize) -> Result<Self, DataFusionError>;
fn set_distributed_passthrough_headers(&mut self, headers: HeaderMap) -> Result<(), DataFusionError>;
#[call(set_distributed_passthrough_headers)]
#[expr($?;Ok(self))]
fn with_distributed_passthrough_headers(self, headers: HeaderMap) -> Result<Self, DataFusionError>;
fn set_distributed_max_tasks_per_stage(&mut self, max_tasks_per_stage: usize) -> Result<(), DataFusionError>;
#[call(set_distributed_max_tasks_per_stage)]
#[expr($?;Ok(self))]
fn with_distributed_max_tasks_per_stage(self, max_tasks_per_stage: usize) -> Result<Self, DataFusionError>;
fn set_distributed_partial_reduce(&mut self, enabled: bool) -> Result<(), DataFusionError>;
#[call(set_distributed_partial_reduce)]
#[expr($?;Ok(self))]
fn with_distributed_partial_reduce(self, enabled: bool) -> Result<Self, DataFusionError>;
fn set_distributed_worker_connection_buffer_budget_bytes(&mut self, budget_bytes: usize) -> Result<(), DataFusionError>;
#[call(set_distributed_worker_connection_buffer_budget_bytes)]
#[expr($?;Ok(self))]
fn with_distributed_worker_connection_buffer_budget_bytes(self, budget_bytes: usize) -> Result<Self, DataFusionError>;
fn set_distributed_work_unit_feed<T, P, F>(&mut self, getter: F)
where
T: ExecutionPlan + 'static,
P: WorkUnitFeedProvider + 'static,
P::WorkUnit: 'static,
F: Fn(&T) -> Option<&WorkUnitFeed<P>> + Send + Sync + 'static;
#[call(set_distributed_work_unit_feed)]
#[expr($;self)]
fn with_distributed_work_unit_feed<T, P, F>(self, getter: F) -> Self
where
T: ExecutionPlan + 'static,
P: WorkUnitFeedProvider + 'static,
P::WorkUnit: 'static,
F: Fn(&T) -> Option<&WorkUnitFeed<P>> + Send + Sync + 'static;
}
}
}