Skip to content

Commit dddd991

Browse files
committed
Add more debugging info to StructBuilder validate_content
1 parent f5097b0 commit dddd991

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

arrow-array/src/builder/struct_builder.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use crate::builder::*;
1919
use crate::{ArrayRef, StructArray};
2020
use arrow_buffer::NullBufferBuilder;
21-
use arrow_schema::{DataType, Fields, IntervalUnit, TimeUnit};
21+
use arrow_schema::{DataType, Fields, IntervalUnit, SchemaBuilder, TimeUnit};
2222
use std::any::Any;
2323
use std::sync::Arc;
2424

@@ -286,9 +286,20 @@ impl StructBuilder {
286286
if self.fields.len() != self.field_builders.len() {
287287
panic!("Number of fields is not equal to the number of field_builders.");
288288
}
289-
if !self.field_builders.iter().all(|x| x.len() == self.len()) {
290-
panic!("StructBuilder and field_builders are of unequal lengths.");
291-
}
289+
self.field_builders.iter().enumerate().for_each(|(idx, x)| {
290+
if x.len() != self.len() {
291+
let builder = SchemaBuilder::from(&self.fields);
292+
let schema = builder.finish();
293+
294+
panic!("{}", format!(
295+
"StructBuilder ({:?}) and field_builder {:?} are of unequal lengths: ({} != {}).",
296+
schema,
297+
self.fields[idx].data_type(),
298+
self.len(),
299+
x.len()
300+
));
301+
}
302+
});
292303
}
293304
}
294305

0 commit comments

Comments
 (0)