Skip to content

Commit cfc6594

Browse files
committed
bench: cover non-nullable union schemas
Extend the union construction benchmark with 10, 100, and 1,000 non-nullable children so the full nullability scan and metadata merge fallback can be measured independently of its optimization. Generated-by: OpenAI Codex
1 parent c18e5d9 commit cfc6594

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎datafusion/physical-plan/benches/union_schema.rs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
//! the scan runs, fails on the final child, then the full merge runs anyway.
2626
//! - `names_differ`: the first field is renamed in every child but the first,
2727
//! the common real-world unequal union where equality fails immediately.
28+
//!
29+
//! The non-nullable cases also require scanning all children to determine
30+
//! output nullability, rather than stopping at the first nullable field.
2831
2932
use std::collections::HashMap;
3033
use std::sync::Arc;
@@ -45,10 +48,10 @@ fn metadata(tag: &str, i: usize) -> HashMap<String, String> {
4548
.collect()
4649
}
4750

48-
fn flat_schema() -> Schema {
51+
fn flat_schema(nullable: bool) -> Schema {
4952
let fields: Vec<Field> = (0..NUM_FIELDS)
5053
.map(|i| {
51-
Field::new(format!("col_{i}"), DataType::Int64, true)
54+
Field::new(format!("col_{i}"), DataType::Int64, nullable)
5255
.with_metadata(metadata("f", i))
5356
})
5457
.collect();
@@ -120,8 +123,9 @@ fn children_last_differs(schema: &Schema, n: usize) -> Vec<Arc<dyn ExecutionPlan
120123

121124
fn bench_union_construction(c: &mut Criterion) {
122125
for (suffix, schema, sizes) in [
123-
("", flat_schema(), &[100usize, 1000, 4000][..]),
126+
("", flat_schema(true), &[100usize, 1000, 4000][..]),
124127
("_nested", nested_schema(), &[1000, 4000][..]),
128+
("_non_nullable", flat_schema(false), &[10, 100, 1000][..]),
125129
] {
126130
let mut group = c.benchmark_group(format!("union_exec_try_new{suffix}"));
127131
for &n in sizes {

0 commit comments

Comments
 (0)