Skip to content

Commit

Permalink
fix: avro_to_arrow: Handle avro nested nullable struct (union)
Browse files Browse the repository at this point in the history
Corrects handling of a nullable struct union.

Signed-off-by: 🐼 Samrose Ahmed 🐼 <[email protected]>
  • Loading branch information
Samrose-Ahmed committed Sep 27, 2023
1 parent 32dfbb0 commit ff8bc73
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -766,14 +766,20 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> {
let len = rows.len();
let num_bytes = bit_util::ceil(len, 8);
let mut null_buffer = MutableBuffer::from_len_zeroed(num_bytes);
let empty_vec = vec![];
let struct_rows = rows
.iter()
.enumerate()
.map(|(i, row)| (i, self.field_lookup(field.name(), row)))
.map(|(i, v)| {
let v = v.map(maybe_resolve_union);
if let Some(Value::Record(value)) = v {
bit_util::set_bit(&mut null_buffer, i);
value
} else if v.is_none() {
&empty_vec
} else if let Some(Value::Null) = v {
&empty_vec
} else {
panic!("expected struct got {v:?}");
}
Expand Down

0 comments on commit ff8bc73

Please sign in to comment.