GH-50249: [C++] Add ArrayBuilder::IsValid and ArrayBuilder::IsNull#50402
GH-50249: [C++] Add ArrayBuilder::IsValid and ArrayBuilder::IsNull#50402andishgar wants to merge 2 commits into
Conversation
|
|
pitrou
left a comment
There was a problem hiding this comment.
Thanks @andishgar , just a suggestion to update the docstring
| /// 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). |
There was a problem hiding this comment.
It's not exactly that it does not work, it's that it doesn't account for logical nulls.
| /// 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). |
| case Type::SPARSE_UNION: | ||
| case Type::DENSE_UNION: | ||
| case Type::RUN_END_ENCODED: |
There was a problem hiding this comment.
These three should return true perhaps?
There was a problem hiding this comment.
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.
Rationale for this change
ArrayBuilderdoes not provide a public API to check whether an element is null.What changes are included in this PR?
Add
ArrayBuilder::IsNullandArrayBuilder::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::IsNullandArrayBuilder::IsValid.