diff --git a/src/io/parquet/write/dictionary.rs b/src/io/parquet/write/dictionary.rs index 52b6a407a5..a18b654e03 100644 --- a/src/io/parquet/write/dictionary.rs +++ b/src/io/parquet/write/dictionary.rs @@ -6,6 +6,7 @@ use parquet2::{ }; use super::binary::encode_plain as binary_encode_plain; +use super::fixed_len_bytes::encode_plain as fixed_binary_encode_plain; use super::primitive::encode_plain as primitive_encode_plain; use super::utf8::encode_plain as utf8_encode_plain; use crate::array::{Array, DictionaryArray, DictionaryKey, PrimitiveArray}; @@ -172,6 +173,12 @@ pub fn array_to_pages( binary_encode_plain::(values, false, &mut buffer); EncodedDictPage::new(buffer, values.len()) } + DataType::FixedSizeBinary(_) => { + let mut buffer = vec![]; + let array = array.values().as_any().downcast_ref().unwrap(); + fixed_binary_encode_plain(array, false, &mut buffer); + EncodedDictPage::new(buffer, array.len()) + } other => { return Err(ArrowError::NotYetImplemented(format!( "Writing dictionary arrays to parquet only support data type {:?}", diff --git a/src/io/parquet/write/fixed_len_bytes.rs b/src/io/parquet/write/fixed_len_bytes.rs index 304a79d52f..e129ab66c4 100644 --- a/src/io/parquet/write/fixed_len_bytes.rs +++ b/src/io/parquet/write/fixed_len_bytes.rs @@ -13,6 +13,19 @@ use crate::{ io::parquet::read::is_type_nullable, }; +pub(crate) fn encode_plain(array: &FixedSizeBinaryArray, is_optional: bool, buffer: &mut Vec) { + // append the non-null values + if is_optional { + array.iter().for_each(|x| { + if let Some(x) = x { + buffer.extend_from_slice(x); + } + }) + } else { + buffer.extend_from_slice(array.values()); + } +} + pub fn array_to_page( array: &FixedSizeBinaryArray, options: WriteOptions, @@ -32,17 +45,7 @@ pub fn array_to_page( let definition_levels_byte_length = buffer.len(); - if is_optional { - // append the non-null values - array.iter().for_each(|x| { - if let Some(x) = x { - buffer.extend_from_slice(x); - } - }); - } else { - // append all values - buffer.extend_from_slice(array.values()); - } + encode_plain(array, is_optional, &mut buffer); let statistics = if options.write_statistics { build_statistics(array, descriptor.clone())