Skip to content

Commit 89e96b4

Browse files
authored
Derive Clone for more ExecutionPlans (#13203)
* Derive `Clone` for more ExecutionPlans * improve docs
1 parent 344f089 commit 89e96b4

24 files changed

+36
-19
lines changed

datafusion/physical-plan/src/aggregates/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ impl From<StreamType> for SendableRecordBatchStream {
344344
}
345345

346346
/// Hash aggregate execution plan
347-
#[derive(Debug)]
347+
#[derive(Debug, Clone)]
348348
pub struct AggregateExec {
349349
/// Aggregation mode (full, partial)
350350
mode: AggregateMode,

datafusion/physical-plan/src/coalesce_batches.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ use futures::stream::{Stream, StreamExt};
4848
/// reaches the `fetch` value.
4949
///
5050
/// See [`BatchCoalescer`] for more information
51-
#[derive(Debug)]
51+
#[derive(Debug, Clone)]
5252
pub struct CoalesceBatchesExec {
5353
/// The input plan
5454
input: Arc<dyn ExecutionPlan>,

datafusion/physical-plan/src/coalesce_partitions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use datafusion_execution::TaskContext;
3636

3737
/// Merge execution plan executes partitions in parallel and combines them into a single
3838
/// partition. No guarantees are made about the order of the resulting partition.
39-
#[derive(Debug)]
39+
#[derive(Debug, Clone)]
4040
pub struct CoalescePartitionsExec {
4141
/// Input execution plan
4242
input: Arc<dyn ExecutionPlan>,

datafusion/physical-plan/src/empty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use datafusion_physical_expr::EquivalenceProperties;
3535
use log::trace;
3636

3737
/// Execution plan for empty relation with produce_one_row=false
38-
#[derive(Debug)]
38+
#[derive(Debug, Clone)]
3939
pub struct EmptyExec {
4040
/// The schema for the produced row
4141
schema: SchemaRef,

datafusion/physical-plan/src/filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ use log::trace;
5454

5555
/// FilterExec evaluates a boolean predicate against all input batches to determine which rows to
5656
/// include in its output batches.
57-
#[derive(Debug)]
57+
#[derive(Debug, Clone)]
5858
pub struct FilterExec {
5959
/// The expression to filter on. This expression must evaluate to a boolean value.
6060
predicate: Arc<dyn PhysicalExpr>,

datafusion/physical-plan/src/insert.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ pub type FileSinkExec = DataSinkExec;
7979
/// Execution plan for writing record batches to a [`DataSink`]
8080
///
8181
/// Returns a single row with the number of values written
82+
#[derive(Clone)]
8283
pub struct DataSinkExec {
8384
/// Input plan that produces the record batches to be written.
8485
input: Arc<dyn ExecutionPlan>,

datafusion/physical-plan/src/joins/cross_join.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ use futures::{ready, Stream, StreamExt, TryStreamExt};
4949
/// Data of the left side
5050
type JoinLeftData = (RecordBatch, MemoryReservation);
5151

52+
#[allow(rustdoc::private_intra_doc_links)]
5253
/// executes partitions in parallel and combines them into a set of
5354
/// partitions by combining all values from the left with all values on the right
55+
///
56+
/// Note that the `Clone` trait is not implemented for this struct due to the
57+
/// `left_fut` [`OnceAsync`], which is used to coordinate the loading of the
58+
/// left side with the processing in each output stream.
5459
#[derive(Debug)]
5560
pub struct CrossJoinExec {
5661
/// left (build) side which gets loaded in memory

datafusion/physical-plan/src/joins/hash_join.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ impl JoinLeftData {
136136
}
137137
}
138138

139+
#[allow(rustdoc::private_intra_doc_links)]
139140
/// Join execution plan: Evaluates eqijoin predicates in parallel on multiple
140141
/// partitions using a hash table and an optional filter list to apply post
141142
/// join.
@@ -293,6 +294,10 @@ impl JoinLeftData {
293294
/// │ "dimension" │ │ "fact" │
294295
/// └───────────────┘ └───────────────┘
295296
/// ```
297+
///
298+
/// Note that the `Clone` trait is not implemented for this struct due to the
299+
/// `left_fut` [`OnceAsync`], which is used to coordinate the loading of the
300+
/// left side with the processing in each output stream.
296301
#[derive(Debug)]
297302
pub struct HashJoinExec {
298303
/// left (build) side which gets hashed

datafusion/physical-plan/src/joins/nested_loop_join.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ impl JoinLeftData {
105105
}
106106
}
107107

108+
#[allow(rustdoc::private_intra_doc_links)]
108109
/// NestedLoopJoinExec is build-probe join operator, whose main task is to
109110
/// perform joins without any equijoin conditions in `ON` clause.
110111
///
@@ -140,6 +141,9 @@ impl JoinLeftData {
140141
/// "reports" about probe phase completion (which means that "visited" bitmap won't be
141142
/// updated anymore), and only the last thread, reporting about completion, will return output.
142143
///
144+
/// Note that the `Clone` trait is not implemented for this struct due to the
145+
/// `left_fut` [`OnceAsync`], which is used to coordinate the loading of the
146+
/// left side with the processing in each output stream.
143147
#[derive(Debug)]
144148
pub struct NestedLoopJoinExec {
145149
/// left side

datafusion/physical-plan/src/joins/sort_merge_join.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ use crate::{
7171

7272
/// join execution plan executes partitions in parallel and combines them into a set of
7373
/// partitions.
74-
#[derive(Debug)]
74+
#[derive(Debug, Clone)]
7575
pub struct SortMergeJoinExec {
7676
/// Left sorted joining execution plan
7777
pub left: Arc<dyn ExecutionPlan>,

datafusion/physical-plan/src/joins/symmetric_hash_join.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ const HASHMAP_SHRINK_SCALE_FACTOR: usize = 4;
167167
/// making the smallest value in 'left_sorted' 1231 and any rows below (since ascending)
168168
/// than that can be dropped from the inner buffer.
169169
/// ```
170-
#[derive(Debug)]
170+
#[derive(Debug, Clone)]
171171
pub struct SymmetricHashJoinExec {
172172
/// Left side stream
173173
pub(crate) left: Arc<dyn ExecutionPlan>,

datafusion/physical-plan/src/limit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use futures::stream::{Stream, StreamExt};
3939
use log::trace;
4040

4141
/// Limit execution plan
42-
#[derive(Debug)]
42+
#[derive(Debug, Clone)]
4343
pub struct GlobalLimitExec {
4444
/// Input execution plan
4545
input: Arc<dyn ExecutionPlan>,

datafusion/physical-plan/src/memory.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use datafusion_physical_expr::{EquivalenceProperties, LexOrdering};
4040
use futures::Stream;
4141

4242
/// Execution plan for reading in-memory batches of data
43+
#[derive(Clone)]
4344
pub struct MemoryExec {
4445
/// The partitions to query
4546
partitions: Vec<Vec<RecordBatch>>,

datafusion/physical-plan/src/placeholder_row.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use datafusion_physical_expr::EquivalenceProperties;
3737
use log::trace;
3838

3939
/// Execution plan for empty relation with produce_one_row=true
40-
#[derive(Debug)]
40+
#[derive(Debug, Clone)]
4141
pub struct PlaceholderRowExec {
4242
/// The schema for the produced row
4343
schema: SchemaRef,

datafusion/physical-plan/src/recursive_query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use futures::{ready, Stream, StreamExt};
5353
/// Note that there won't be any limit or checks applied to detect
5454
/// an infinite recursion, so it is up to the planner to ensure that
5555
/// it won't happen.
56-
#[derive(Debug)]
56+
#[derive(Debug, Clone)]
5757
pub struct RecursiveQueryExec {
5858
/// Name of the query handler
5959
name: String,

datafusion/physical-plan/src/repartition/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ impl BatchPartitioner {
399399
/// Paper](https://w6113.github.io/files/papers/volcanoparallelism-89.pdf)
400400
/// which uses the term "Exchange" for the concept of repartitioning
401401
/// data across threads.
402-
#[derive(Debug)]
402+
#[derive(Debug, Clone)]
403403
pub struct RepartitionExec {
404404
/// Input execution plan
405405
input: Arc<dyn ExecutionPlan>,

datafusion/physical-plan/src/sorts/sort.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ pub(crate) fn lexsort_to_indices_multi_columns(
675675
///
676676
/// Support sorting datasets that are larger than the memory allotted
677677
/// by the memory manager, by spilling to disk.
678-
#[derive(Debug)]
678+
#[derive(Debug, Clone)]
679679
pub struct SortExec {
680680
/// Input schema
681681
pub(crate) input: Arc<dyn ExecutionPlan>,

datafusion/physical-plan/src/sorts/sort_preserving_merge.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ use log::{debug, trace};
7171
///
7272
/// If any of the input partitions return an error, the error is propagated to
7373
/// the output and inputs are not polled again.
74-
#[derive(Debug)]
74+
#[derive(Debug, Clone)]
7575
pub struct SortPreservingMergeExec {
7676
/// Input plan
7777
input: Arc<dyn ExecutionPlan>,

datafusion/physical-plan/src/streaming.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pub trait PartitionStream: Debug + Send + Sync {
5555
///
5656
/// If your source can be represented as one or more [`PartitionStream`]s, you can
5757
/// use this struct to implement [`ExecutionPlan`].
58+
#[derive(Clone)]
5859
pub struct StreamingTableExec {
5960
partitions: Vec<Arc<dyn PartitionStream>>,
6061
projection: Option<Arc<[usize]>>,

datafusion/physical-plan/src/union.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ use tokio::macros::support::thread_rng_n;
8585
/// │Input 1 │ │Input 2 │
8686
/// └─────────────────┘ └──────────────────┘
8787
/// ```
88-
#[derive(Debug)]
88+
#[derive(Debug, Clone)]
8989
pub struct UnionExec {
9090
/// Input execution plan
9191
inputs: Vec<Arc<dyn ExecutionPlan>>,
@@ -298,7 +298,7 @@ impl ExecutionPlan for UnionExec {
298298
/// | |-----------------+
299299
/// +---------+
300300
/// ```
301-
#[derive(Debug)]
301+
#[derive(Debug, Clone)]
302302
pub struct InterleaveExec {
303303
/// Input execution plan
304304
inputs: Vec<Arc<dyn ExecutionPlan>>,

datafusion/physical-plan/src/unnest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ use log::trace;
5656
/// Thus the original RecordBatch with dimension (n x m) may have new dimension (n' x m')
5757
///
5858
/// See [`UnnestOptions`] for more details and an example.
59-
#[derive(Debug)]
59+
#[derive(Debug, Clone)]
6060
pub struct UnnestExec {
6161
/// Input execution plan
6262
input: Arc<dyn ExecutionPlan>,

datafusion/physical-plan/src/values.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use datafusion_execution::TaskContext;
3636
use datafusion_physical_expr::EquivalenceProperties;
3737

3838
/// Execution plan for values list based relation (produces constant rows)
39-
#[derive(Debug)]
39+
#[derive(Debug, Clone)]
4040
pub struct ValuesExec {
4141
/// The schema
4242
schema: SchemaRef,

datafusion/physical-plan/src/windows/bounded_window_agg_exec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ use indexmap::IndexMap;
6767
use log::debug;
6868

6969
/// Window execution plan
70-
#[derive(Debug)]
70+
#[derive(Debug, Clone)]
7171
pub struct BoundedWindowAggExec {
7272
/// Input plan
7373
input: Arc<dyn ExecutionPlan>,

datafusion/physical-plan/src/windows/window_agg_exec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use datafusion_physical_expr_common::sort_expr::{LexOrdering, LexRequirement};
4646
use futures::{ready, Stream, StreamExt};
4747

4848
/// Window execution plan
49-
#[derive(Debug)]
49+
#[derive(Debug, Clone)]
5050
pub struct WindowAggExec {
5151
/// Input plan
5252
pub(crate) input: Arc<dyn ExecutionPlan>,

0 commit comments

Comments
 (0)