tustvold commented on code in PR #1589: URL: https://github.com/apache/arrow-rs/pull/1589#discussion_r860772343
########## arrow/src/array/builder.rs: ########## @@ -2070,39 +2061,13 @@ impl UnionBuilder { fields: HashMap::default(), type_id_builder: Int8BufferBuilder::new(capacity), value_offset_builder: None, - bitmap_builder: None, } } /// Appends a null to this builder. #[inline] - pub fn append_null(&mut self) -> Result<()> { - if self.bitmap_builder.is_none() { - let mut builder = BooleanBufferBuilder::new(self.len + 1); - for _ in 0..self.len { - builder.append(true); - } - self.bitmap_builder = Some(builder) - } - self.bitmap_builder - .as_mut() - .expect("Cannot be None") - .append(false); - - self.type_id_builder.append(i8::default()); - - match &mut self.value_offset_builder { - // Handle dense union - Some(value_offset_builder) => value_offset_builder.append(i32::default()), - // Handle sparse union - None => { - for (_, fd) in self.fields.iter_mut() { - fd.append_null_dynamic()?; - } - } - }; - self.len += 1; - Ok(()) + pub fn append_null<T: ArrowPrimitiveType>(&mut self, type_name: &str) -> Result<()> { Review Comment: The short answer is that UnionArray nulls are typed and so two arrays are not equal if they have nulls in different child arrays. There is also the case of appending a null to an empty UnionArray... -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org