diff --git a/arrow-array/src/builder/null_builder.rs b/arrow-array/src/builder/null_builder.rs index 59086dffa90..1da3fcd64af 100644 --- a/arrow-array/src/builder/null_builder.rs +++ b/arrow-array/src/builder/null_builder.rs @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -use crate::builder::ArrayBuilder; +use crate::builder::{SpecificArrayBuilder, ArrayBuilder}; use crate::{ArrayRef, NullArray}; use arrow_data::ArrayData; use arrow_schema::DataType; @@ -146,6 +146,43 @@ impl ArrayBuilder for NullBuilder { } } +impl SpecificArrayBuilder for NullBuilder { + type Output = NullArray; + type Item<'a> = (); + + fn finish(&mut self) -> Arc { + Arc::new(self.finish()) + } + + fn finish_cloned(&self) -> Arc { + Arc::new(self.finish_cloned()) + } + + fn append_value<'a>(&'a mut self, value: Self::Item<'a>) { + self.append_null(); + } + + fn append_value_ref<'a>(&'a mut self, value: &'a Self::Item<'a>) { + self.append_null(); + } + + fn append_null(&mut self) { + self.append_null(); + } + + fn append_output<'a>(&'a mut self, output: &'a Self::Output) { + self.len += output.len(); + } + + fn append_nulls(&mut self, n: usize) { + self.append_nulls(n) + } + + fn append_option<'a>(&'a mut self, v: Option>) { + self.append_null() + } +} + #[cfg(test)] mod tests { use super::*;