helgikrs opened a new issue #846:
URL: https://github.com/apache/arrow-rs/issues/846


   Ipc serialization and deserialization of a column containing a dictionary 
nested within a struct does not seem to work as expected right now. Here's a 
small code snippet exhibiting that behavior.
   
   ```rust
   use arrow::{
       array::{self, ArrayRef, StructArray},
       datatypes::{self, Field, Schema},
       ipc::{reader::FileReader, writer::FileWriter},
       record_batch::RecordBatch,
   };
   use std::sync::Arc;
   
   fn main() {
       // This works
       // let inner: array::StringArray = vec![Some("a"), Some("b"), 
Some("a")].into_iter().collect();
   
       // This does not
       let inner: array::DictionaryArray<datatypes::Int32Type> =
           vec!["a", "b", "a"].into_iter().collect();
   
       let array = Arc::new(inner) as ArrayRef;
   
       let dctfield = Field::new("dict", array.data_type().clone(), false);
   
       let s = StructArray::from(vec![(dctfield, array)]);
       let struct_array = Arc::new(s) as ArrayRef;
   
       let schema = Arc::new(Schema::new(vec![Field::new(
           "struct",
           struct_array.data_type().clone(),
           false,
       )]));
   
       let batch = RecordBatch::try_new(schema.clone(), 
vec![struct_array]).unwrap();
   
       let mut buf = Vec::new();
       let mut writer = FileWriter::try_new(&mut buf, &schema).unwrap();
       writer.write(&batch).unwrap();
       writer.finish().unwrap();
       drop(writer);
   
       let reader = FileReader::try_new(std::io::Cursor::new(buf)).unwrap();
       let batch2: Result<Vec<_>, _> = reader.collect();
   
       assert_eq!(batch, batch2.unwrap()[0]);
   }
   ```
   
   The code panics when the struct field is a dictionary, but works as expected 
for other types.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to