@@ -50,7 +50,43 @@ use crate::{
50
50
use datafusion_physical_expr:: sort_expr_list_eq_strict_order;
51
51
use tokio:: macros:: support:: thread_rng_n;
52
52
53
- /// UNION ALL execution plan
53
+ /// `UnionExec`: `UNION ALL` execution plan.
54
+ ///
55
+ /// `UnionExec` combines multiple inputs with the same schema by
56
+ /// concatenating the partitions. It does not mix or copy data within
57
+ /// or across partitions. Thus if the input partitions are sorted, the
58
+ /// output partitions of the union are also sorted.
59
+ ///
60
+ /// For example, given a `UnionExec` of two inputs, with `N`
61
+ /// partitions, and `M` partitions, there will be `N+M` output
62
+ /// partitions. The first `N` output partitions are from Input 1
63
+ /// partitions, and then next `M` output partitions are from Input 2.
64
+ ///
65
+ /// ```text
66
+ /// ▲ ▲ ▲ ▲
67
+ /// │ │ │ │
68
+ /// Output │ ... │ │ │
69
+ /// Partitions │0 │N-1 │ N │N+M-1
70
+ ///(passes through ┌────┴───────┴───────────┴─────────┴───┐
71
+ /// the N+M input │ UnionExec │
72
+ /// partitions) │ │
73
+ /// └──────────────────────────────────────┘
74
+ /// ▲
75
+ /// │
76
+ /// │
77
+ /// Input ┌────────┬─────┴────┬──────────┐
78
+ /// Partitions │ ... │ │ ... │
79
+ /// 0 │ │ N-1 │ 0 │ M-1
80
+ /// ┌────┴────────┴───┐ ┌───┴──────────┴───┐
81
+ /// │ │ │ │
82
+ /// │ │ │ │
83
+ /// │ │ │ │
84
+ /// │ │ │ │
85
+ /// │ │ │ │
86
+ /// │ │ │ │
87
+ /// │Input 1 │ │Input 2 │
88
+ /// └─────────────────┘ └──────────────────┘
89
+ /// ```
54
90
#[ derive( Debug ) ]
55
91
pub struct UnionExec {
56
92
/// Input execution plan
@@ -158,7 +194,7 @@ impl ExecutionPlan for UnionExec {
158
194
159
195
/// Specifies whether this plan generates an infinite stream of records.
160
196
/// If the plan does not support pipelining, but it its input(s) are
161
- /// infinite, returns an error to indicate this.
197
+ /// infinite, returns an error to indicate this.
162
198
fn unbounded_output ( & self , children : & [ bool ] ) -> Result < bool > {
163
199
Ok ( children. iter ( ) . any ( |x| * x) )
164
200
}
0 commit comments