Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions rust/lance-arrow/src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ pub fn try_inline_value(scalar: &ArrayRef) -> Option<Vec<u8>> {
if data.buffers().len() != 1 {
return None;
}

let byte_width = data.data_type().byte_width_opt();
let bytes = data.buffers()[0].as_slice();
if byte_width.is_none() || bytes.len() != byte_width.unwrap() {
Comment thread
wjones127 marked this conversation as resolved.
Outdated
return None;
}
if bytes.len() > INLINE_VALUE_MAX_BYTES {
return None;
}
Expand Down
27 changes: 27 additions & 0 deletions rust/lance-encoding/src/encodings/logical/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6313,6 +6313,33 @@ mod tests {
check_round_trip_encoding_of_data(vec![arr], &test_cases, HashMap::new()).await;
}

#[tokio::test]
async fn test_constant_layout_out_of_line_boolean_v2_2() {
use crate::format::pb21::page_layout::Layout;

let arr: ArrayRef = Arc::new(arrow_array::BooleanArray::from_iter(std::iter::repeat_n(
Some(true),
512,
)));
let field = arrow_schema::Field::new("c", DataType::Boolean, true);
let page = encode_first_page(field, arr.clone(), LanceFileVersion::V2_2).await;

let PageEncoding::Structural(layout) = &page.description else {
panic!("Expected structural encoding");
};
let Layout::ConstantLayout(layout) = layout.layout.as_ref().unwrap() else {
panic!("Expected constant layout in slot 2");
};
assert!(layout.inline_value.is_none());
assert_eq!(page.data.len(), 1);

let test_cases = TestCases::default()
.with_min_file_version(LanceFileVersion::V2_2)
.with_max_file_version(LanceFileVersion::V2_2)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove the with_max_file_version? There is no reason this test should stop working in future versions.

.with_page_sizes(vec![4096]);
check_round_trip_encoding_of_data(vec![arr], &test_cases, HashMap::new()).await;
}

#[tokio::test]
async fn test_constant_layout_nullable_item_v2_2() {
use crate::format::pb21::page_layout::Layout;
Expand Down
Loading