danhhz opened a new issue, #6086:
URL: https://github.com/apache/arrow-rs/issues/6086
**Describe the bug**
It seems that a BinaryViewArray of a single `Some(&[])` comes back as `None`
(null) after being roundtripped through parquet. A non-empty byte slice, such
as `Some(&[1])` works, however.
**To Reproduce**
Using version 52.1.0
```
#[test]
fn binary_view_bug() {
#[track_caller]
fn roundtrips(x: &[u8]) {
let before = BinaryViewArray::from(vec![x]);
let batch =
RecordBatch::try_from_iter(vec![("val", Arc::new(before.clone())
as ArrayRef)])
.unwrap();
let mut buf = Vec::new();
let mut writer = ArrowWriter::try_new(&mut buf, batch.schema(),
None).unwrap();
writer.write(&batch).unwrap();
writer.close().unwrap();
let builder =
ParquetRecordBatchReaderBuilder::try_new(Bytes::from(buf)).unwrap();
let mut reader = builder.build().unwrap();
let batch = reader.next().unwrap().unwrap();
let after = batch.columns()[0].as_binary_view();
assert_eq!(
before.iter().collect::<Vec<_>>(),
after.iter().collect::<Vec<_>>()
);
}
roundtrips(&[1]); // This one works
roundtrips(&[]); // This one fails
}
```
The output on failure is
```
assertion `left == right` failed
left: [Some([])]
right: [None]
```
**Expected behavior**
The value should be `Some([])` on decode.
**Additional context**
<!--
Add any other context about the problem here.
-->
--
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]