Skip to content

docs(parquet): add SAFETY comments for build_unchecked in array readers - #12119

Merged
Rich-T-kid merged 2 commits into
apache:mainfrom
EaswarKilari:fix-7044-parquet-safety-comments
Nov 9, 2026
Merged

Rich-T-kid merged 2 commits into
apache:mainfrom
EaswarKilari:fix-7044-parquet-safety-comments

Conversation

@EaswarKilari

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

A few build_unchecked calls in the parquet array readers had no comment explaining why they're safe.

What changes are included in this PR?

  • Added SAFETY comments in the list, fixed size list and fixed len byte array readers.
  • In the fixed len byte array reader, the buffer length check was a debug_assert, so it's now a real check that returns an error in release builds too.

I left OffsetBuffer::into_array out for now, since #11144 is fixing the UTF-8 issue there (#11140). Happy to add the comment once that's merged.

Are these changes tested?

Covered by existing tests. The new check shouldn't trigger for valid files.

Are there any significant user-facing changes?

No.

@github-actions github-actions Bot added the parquet Changes to the parquet crate label Nov 7, 2026

@Rich-T-kid Rich-T-kid left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks @EaswarKilari

Comment on lines -205 to -212
debug_assert_eq!(
record_data.buffer.len(),
len * self.byte_length,
"fixed-len byte array buffer size mismatch: {} bytes for {} elements of size {}",
record_data.buffer.len(),
len,
self.byte_length,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice, I think its better to replace this with actual validation.

len,
self.byte_length,
);
if record_data.buffer.len() != len * self.byte_length {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we actually make this a checked_mul just to avoid weird behavoir in the unlikely case it overflows

@Rich-T-kid Rich-T-kid added the documentation Improvements or additions to documentation label Nov 8, 2026
@alamb

alamb commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

❤️

@Rich-T-kid

Copy link
Copy Markdown
Contributor

for the sake of getting this over line I updated the PR. thank you @EaswarKilari

@Rich-T-kid
Rich-T-kid added this pull request to the merge queue Nov 9, 2026
Merged via the queue into apache:main with commit 5829854 Nov 9, 2026
20 checks passed
@EaswarKilari

Copy link
Copy Markdown
Contributor Author

thank you @Rich-T-kid . Sorry for the delay (was busy in some other work).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation parquet Changes to the parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants