Mola-maker opened a new pull request, #12403:
URL: https://github.com/apache/arrow-rs/pull/12403

   Closes #12395.
   
   `MapBuilder::append` trusted the child builders' lengths for the next 
offset. Finishing a child resets its length, so the next offset could be 
smaller than the last one already recorded. The finished array then had 
decreasing offsets, which is invalid.
   
   `append` and `append_nulls` now reject a next offset that is smaller than 
the last recorded one. They return an error before either buffer changes. 
`finish` and `finish_cloned` now check the recorded offsets before building. 
The offsets must be non-decreasing, and the last offset must fit inside the 
finished key and value arrays. A longer child is allowed, since those entries 
are not part of a map slot yet.
   
   ## Are these changes tested?
   
   Yes. Three new tests in `builder::map_builder::tests`. 
`test_append_rejects_decreasing_offset_after_child_finish` covers `append` and 
`append_nulls` after finishing both children. Both return 
`InvalidArgumentError`, and the builder is unchanged. 
`test_finish_panics_when_child_was_finished_after_append` covers `finish` after 
the same sequence. `test_finish_allows_uncommitted_trailing_entries` covers the 
allowed case. Entries appended after the last `append` stay in the child arrays 
and are not part of the map.
   
   Before the fix, the first two tests fail. `append` returns `Ok`, and 
`finish` builds an array with decreasing offsets. After the fix, all three 
pass. Full `arrow-array` lib suite: 766 passed, 0 failed, 1 ignored. `cargo fmt 
--check` and `cargo clippy --all-targets --all-features -D warnings` are clean.
   
   Note: #12353 touches the same `finish` code for performance, but it does not 
validate offsets. This fix is independent of it.
   
   AI usage disclosure: this PR was developed and tested with AI assistance 
(harness: Claude; model: Claude Opus 5.5).
   


-- 
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]

Reply via email to