adriangb opened a new issue, #6221:
URL: https://github.com/apache/arrow-rs/issues/6221
```rust
use std::sync::Arc;
use arrow::array::{DictionaryArray, Int32Array, Int8Array, LargeStringArray,
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::LargeUtf8)),
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(LargeStringArray::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();
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();
}
```
If you do just one column at a time, it works 🤔
--
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]