adriangb commented on issue #6221:
URL: https://github.com/apache/arrow-rs/issues/6221#issuecomment-2278598753

   Also if I replace the `LargeUtf8Array` with `Utf8` it works:
   
   ```rust
   use std::sync::Arc;
   
   use arrow::array::{DictionaryArray, Int32Array, Int8Array, RecordBatch, 
StringArray};
   use arrow_ipc::{reader::StreamReader, writer::{IpcWriteOptions, 
StreamWriter}};
   use arrow_schema::{DataType, Field, Schema};
   use bytes::{BytesMut, BufMut, Buf};
   
   #[tokio::main]
   async fn main() {
       let schema = Arc::new(
           Schema::new(
               vec![
                   Field::new("a", 
DataType::Dictionary(Box::new(DataType::Int32), Box::new(DataType::Utf8)), 
false),
                   Field::new("b", 
DataType::Dictionary(Box::new(DataType::Int8), Box::new(DataType::Utf8)), 
false),
               ]
           )
       );
   
       let a_array = DictionaryArray::new(
           Int32Array::from(vec![Some(0)]),
           Arc::new(StringArray::from(vec![Some("hello")])),
       );
       let b_array = DictionaryArray::new(
           Int8Array::from(vec![Some(0)]),
           Arc::new(StringArray::from(vec![Some("world")])),
       );
   
       let batch = RecordBatch::try_new(
           schema.clone(),
           vec![
               Arc::new(a_array),
               Arc::new(b_array),
           ],
       ).unwrap();
   
       for indices in vec![vec![0], vec![1], vec![0, 1]] {
           println!("indices: {:?}", indices);
           let batch = batch.project(&indices).unwrap();
           let options = IpcWriteOptions::default();
           let schema = Arc::unwrap_or_clone(batch.schema());
           let mut written_bytes = BytesMut::new().writer();
           {
               let mut writer = StreamWriter::try_new_with_options(&mut 
written_bytes, &schema, options).unwrap();
               writer.write(&batch).unwrap();
               writer.finish().unwrap();
           }
           let written_bytes = written_bytes.into_inner().freeze();
   
           let reader = StreamReader::try_new(written_bytes.reader(), 
None).unwrap();
           reader.collect::<Result<Vec<_>, _>>().unwrap();
       }
   }
   ```


-- 
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