@@ -23,6 +23,7 @@ use crate::parsers::{MessageParser, ParserContext};
23
23
use crate :: { Error , LayerIdentifier , MessageLayer } ;
24
24
25
25
struct Ros2ReflectionMessageParser {
26
+ num_rows : usize ,
26
27
message_schema : MessageSchema ,
27
28
fields : Vec < ( String , FixedSizeListBuilder < Box < dyn ArrayBuilder > > ) > ,
28
29
}
@@ -55,6 +56,7 @@ impl Ros2ReflectionMessageParser {
55
56
}
56
57
57
58
Self {
59
+ num_rows,
58
60
message_schema,
59
61
fields,
60
62
}
@@ -97,11 +99,36 @@ impl MessageParser for Ros2ReflectionMessageParser {
97
99
let timelines = ctx. build_timelines ( ) ;
98
100
99
101
let Self {
102
+ num_rows,
100
103
message_schema,
101
104
fields,
102
105
} = * self ;
103
106
104
107
let archetype_name = message_schema. spec . name . clone ( ) . replace ( '/' , "." ) ;
108
+
109
+ if fields. is_empty ( ) {
110
+ // Create a list array with `num_rows` entries, where each entry is an empty list
111
+ let empty_list = arrow:: array:: ListArray :: new_null (
112
+ std:: sync:: Arc :: new ( Field :: new ( "empty" , DataType :: Null , true ) ) ,
113
+ num_rows,
114
+ ) ;
115
+
116
+ let chunk = Chunk :: from_auto_row_ids (
117
+ ChunkId :: new ( ) ,
118
+ entity_path,
119
+ timelines,
120
+ std:: iter:: once ( (
121
+ ComponentDescriptor :: partial ( "empty" )
122
+ . with_builtin_archetype ( archetype_name. clone ( ) ) ,
123
+ empty_list,
124
+ ) )
125
+ . collect ( ) ,
126
+ )
127
+ . map_err ( |err| Error :: Other ( anyhow:: anyhow!( err) ) ) ?;
128
+
129
+ return Ok ( vec ! [ chunk] ) ;
130
+ }
131
+
105
132
let message_chunk = Chunk :: from_auto_row_ids (
106
133
ChunkId :: new ( ) ,
107
134
entity_path,
0 commit comments