JasonLi-cn opened a new issue, #2312:
URL: https://github.com/apache/arrow-rs/issues/2312
**Describe the bug**
<!--
A clear and concise description of what the bug is.
-->
For an Array like StringArray that contains two Buffers, if its Value Buffer
is empty and its Value Offset Buffer is not empty, which means that it contains
all elements of the empty string. In this case, let slice = array.slice(0, n);
sending slice will result in a truncation failure because
buffer_need_truncate() returns false.
**To Reproduce**
<!--
Steps to reproduce the behavior:
-->
```rust
#[test]
fn truncate_ipc_string_array_with_all_empty_string() {
fn create_batch() -> RecordBatch {
let schema = Schema::new(vec![
Field::new("a", DataType::Utf8, true),
]);
let a = StringArray::from(vec![Some(""), Some(""), Some(""),
Some(""), Some("")]);
RecordBatch::try_new(Arc::new(schema), vec![Arc::new(a)])
.unwrap()
}
let record_batch = create_batch();
let record_batch_slice = record_batch.slice(0, 1);
let deserialized_batch = deserialize(serialize(&record_batch_slice));
// actual
assert_eq!(serialize(&record_batch).len(),
serialize(&record_batch_slice).len());
// expected
// assert!(serialize(&record_batch).len() >
serialize(&record_batch_slice).len());
assert_eq!(record_batch_slice, deserialized_batch);
}
```
**Expected behavior**
<!--
A clear and concise description of what you expected to happen.
-->
```rust
// expected
assert!(serialize(&record_batch).len() >
serialize(&record_batch_slice).len());
```
**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]