Skip to content

GH-50249: [C++] Add ArrayBuilder::IsValid and ArrayBuilder::IsNull#50402

Open
andishgar wants to merge 2 commits into
apache:mainfrom
andishgar:IsNull
Open

GH-50249: [C++] Add ArrayBuilder::IsValid and ArrayBuilder::IsNull#50402
andishgar wants to merge 2 commits into
apache:mainfrom
andishgar:IsNull

Conversation

@andishgar

@andishgar andishgar commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

ArrayBuilder does not provide a public API to check whether an element is null.

What changes are included in this PR?

Add ArrayBuilder::IsNull and ArrayBuilder::IsValid.

Are these changes tested?

Yes, I ran the relevant unit tests.

Are there any user-facing changes?

Yes. This PR adds the public APIs ArrayBuilder::IsNull and ArrayBuilder::IsValid.

@andishgar andishgar requested a review from pitrou as a code owner July 7, 2026 04:05
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #50249 has been automatically assigned in GitHub to PR creator.

@pitrou pitrou left a comment

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.

Thanks @andishgar , just a suggestion to update the docstring

Comment on lines +119 to +120
/// Note that this method does not work for types that do not have a
/// top-level validity bitmap (Union and Run-End Encoded (RLE) types).

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.

It's not exactly that it does not work, it's that it doesn't account for logical nulls.

Suggested change
/// Note that this method does not work for types that do not have a
/// top-level validity bitmap (Union and Run-End Encoded (RLE) types).
/// Unlike Array::IsNull, this method does not account for logical nulls
/// for types that do not have a top-level validity bitmap
/// (Union and Run-End Encoded types).

Comment thread cpp/src/arrow/array/array_test.cc
@github-actions github-actions Bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Jul 7, 2026
Comment on lines +124 to +126
case Type::SPARSE_UNION:
case Type::DENSE_UNION:
case Type::RUN_END_ENCODED:

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.

These three should return true perhaps?

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.

cc @zanmato1984 for opinions

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.

I don't think IsValid has a well-defined logical semantic for Union/RLE builders at the base ArrayBuilder level. Returning false is misleading since it makes every slot look null, while returning true only means there is no top-level null bitmap to invalidate the slot.

So I think we either need to narrow the API semantics/name to physical/top-level validity, e.g. IsPhysicalValid or IsTopLevelValid, or make these builders unsupported for this API instead of pretending to answer logical validity.

Comment thread cpp/src/arrow/array/array_test.cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants