Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions crates/utils/re_mcap/src/layers/ros2_reflection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use arrow::{
array::{
ArrayBuilder, ArrowPrimitiveType, BooleanBuilder, FixedSizeListBuilder, Float32Builder,
Float64Builder, Int8Builder, Int16Builder, Int32Builder, Int64Builder, ListBuilder,
PrimitiveBuilder, StringBuilder, StructBuilder, UInt8Builder, UInt16Builder, UInt32Builder,
UInt64Builder,
PrimitiveBuilder, StringBuilder, StructArray, StructBuilder, UInt8Builder, UInt16Builder,
UInt32Builder, UInt64Builder,
},
datatypes::{
DataType, Field, Fields, Float32Type, Float64Type, Int8Type, Int16Type, Int32Type,
Expand Down Expand Up @@ -96,11 +96,21 @@ impl ArrayBuilder for MessageStructBuilder {
}

fn finish(&mut self) -> arrow::array::ArrayRef {
Arc::new(self.builder.finish())
// Special case for empty structs, e.g. `std_msgs/Empty`
Copy link
Member

@emilk emilk Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see from the code that we're special-casing it, but I cannot see why.

Comment the why, not the what

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an attempt to fix an issue when querying out these empty columns. However, it looks like it might be a datafusion issue: RR-2653.

Marking this as draft until then.

if self.spec.fields.is_empty() {
Arc::new(StructArray::new_empty_fields(self.builder.len(), None))
} else {
Arc::new(self.builder.finish())
}
}

fn finish_cloned(&self) -> arrow::array::ArrayRef {
Arc::new(self.builder.finish_cloned())
// Special case for empty structs, e.g. `std_msgs/Empty`
if self.spec.fields.is_empty() {
Arc::new(StructArray::new_empty_fields(self.builder.len(), None))
} else {
Arc::new(self.builder.finish_cloned())
}
}
}

Expand Down
Loading