Skip to content

Commit 3b86643

Browse files
authored
Minor: Add docstrings to UnionExec (apache#4884)
1 parent 1844d39 commit 3b86643

File tree

1 file changed

+38
-2
lines changed
  • datafusion/core/src/physical_plan

1 file changed

+38
-2
lines changed

datafusion/core/src/physical_plan/union.rs

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,43 @@ use crate::{
5050
use datafusion_physical_expr::sort_expr_list_eq_strict_order;
5151
use tokio::macros::support::thread_rng_n;
5252

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+
/// ```
5490
#[derive(Debug)]
5591
pub struct UnionExec {
5692
/// Input execution plan
@@ -158,7 +194,7 @@ impl ExecutionPlan for UnionExec {
158194

159195
/// Specifies whether this plan generates an infinite stream of records.
160196
/// 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.
162198
fn unbounded_output(&self, children: &[bool]) -> Result<bool> {
163199
Ok(children.iter().any(|x| *x))
164200
}

0 commit comments

Comments
 (0)