Skip to content

Commit 001865d

Browse files
wiedldalamb
authored andcommitted
fix: handle when the left side of the union has no fields (e.g. an empty projection)
1 parent e211960 commit 001865d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

datafusion/physical-plan/src/union.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,13 @@ pub fn can_interleave<T: Borrow<Arc<dyn ExecutionPlan>>>(
468468
}
469469

470470
fn union_schema(inputs: &[Arc<dyn ExecutionPlan>]) -> SchemaRef {
471-
let fields: Vec<Field> = (0..inputs[0].schema().fields().len())
471+
let fields: Vec<Field> = (0..std::cmp::max(
472+
inputs[0].schema().fields().len(),
473+
inputs
474+
.get(1)
475+
.map(|l| l.schema().fields().len())
476+
.unwrap_or_default(),
477+
))
472478
.map(|i| {
473479
inputs
474480
.iter()

0 commit comments

Comments
 (0)