Skip to content

doc: Describe potential footgun in MapArray::keys and values - #11145

Open
neilconway wants to merge 1 commit into
apache:mainfrom
neilconway:neilc/doc-maparray-keys
Open

neilconway wants to merge 1 commit into
apache:mainfrom
neilconway:neilc/doc-maparray-keys

Conversation

@neilconway

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

  • N/A

Rationale for this change

The behavior of the keys and values methods of a MapArray can be a bit surprising. This PR documents that behavior; consistent with the documentation for ListArray::values, which behaves similarly.

What changes are included in this PR?

  • Doc additions only

Are these changes tested?

Existing tests pass.

Are there any user-facing changes?

No.

@neilconway

Copy link
Copy Markdown
Contributor Author

Noticed this in apache/datafusion#25543

@github-actions github-actions Bot added arrow Changes to the arrow crate arrow-array labels Sep 20, 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.

makes sense to me. I left a suggestion but its fine as it is.

In my opinion, the extra info on how to get the specific slice range your looking for would be better placed as a doc comment on [Self::value_offsets].

Comment on lines 218 to +224
/// Returns a reference to the keys of this map
///
/// Note: The map array may not refer to all keys in the returned array.
/// For example, after slicing via [`Self::slice`], the returned array may
/// contain keys both before and after the slice. Use [`Self::value_offsets`]
/// to determine the range of keys for each map. These offsets index into
/// the returned array and may not start at zero.

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.

Suggested change
/// Returns a reference to the keys of this map
///
/// Note: The map array may not refer to all keys in the returned array.
/// For example, after slicing via [`Self::slice`], the returned array may
/// contain keys both before and after the slice. Use [`Self::value_offsets`]
/// to determine the range of keys for each map. These offsets index into
/// the returned array and may not start at zero.
/// Returns a reference to all the keys of this map
/// this includes keys that may have been [`Self::slice`]'ed off

This branch has not been deployed

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

Labels

arrow Changes to the arrow crate arrow-array

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants