jorgecarleitao commented on a change in pull request #9066:
URL: https://github.com/apache/arrow/pull/9066#discussion_r550745492
##########
File path: rust/arrow/src/array/array_struct.rs
##########
@@ -270,27 +270,26 @@ mod tests {
use std::sync::Arc;
- use crate::datatypes::{DataType, Field};
use crate::{
array::BooleanArray, array::Float32Array, array::Float64Array,
array::Int32Array,
array::StringArray, bitmap::Bitmap,
};
+ use crate::{
+ array::Int64Array,
+ datatypes::{DataType, Field},
+ };
use crate::{buffer::Buffer, datatypes::ToByteSlice};
#[test]
fn test_struct_array_builder() {
- let boolean_data = ArrayData::builder(DataType::Boolean)
- .len(4)
- .add_buffer(Buffer::from([false, false, true,
true].to_byte_slice()))
Review comment:
This is the line that triggered this PR. As per this code shows,
`to_byte_slice` can be applied to a `bool` or slice of bools, which promptly
converts it to `u8`. However, `bool` is not represented as `u8` in the Arrow
specification. Consequently, this `ArrayData` is incorrect, as it is built from
4 bytes, but represents 4 slots of booleans (line above), 4 bits or 1 byte (not
4).
This indicates a problem in the `ToByteSlice`, which should not allow `bool`
to be used there. I have concrete ideas to solve this.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]