Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename ArrayData::validate_dict_offsets to ArrayData::validate_values #1889

Merged
merged 1 commit into from Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions arrow/src/array/array_dictionary.rs
Expand Up @@ -114,11 +114,11 @@ impl<'a, K: ArrowPrimitiveType> DictionaryArray<K> {
}

// Safety: `validate` ensures key type is correct, and
// `validate_dictionary_offset` ensures all offsets are within range
// `validate_values` ensures all offsets are within range
let array = unsafe { data.build_unchecked() };

array.validate()?;
array.validate_dictionary_offset()?;
array.validate_values()?;

Ok(array.into())
}
Expand Down
6 changes: 3 additions & 3 deletions arrow/src/array/data.rs
Expand Up @@ -985,7 +985,7 @@ impl ArrayData {
)));
}

self.validate_dictionary_offset()?;
self.validate_values()?;

// validate all children recursively
self.child_data
Expand All @@ -1003,7 +1003,7 @@ impl ArrayData {
Ok(())
}

pub fn validate_dictionary_offset(&self) -> Result<()> {
pub fn validate_values(&self) -> Result<()> {
match &self.data_type {
DataType::Decimal(p, _) => {
let values_buffer: &[i128] = self.typed_buffer(0, self.len)?;
Expand Down Expand Up @@ -2770,7 +2770,7 @@ mod tests {
)
};

let err = data.validate_dictionary_offset().unwrap_err();
let err = data.validate_values().unwrap_err();
assert_eq!(err.to_string(), "Invalid argument error: Offset invariant failure: offset at position 1 out of bounds: 3 > 2");
}
}