GH-49889: [C++][Compute] Handle logical nulls in validity kernels#50269
GH-49889: [C++][Compute] Handle logical nulls in validity kernels#50269hadrian-reppas wants to merge 9 commits into
Conversation
|
Thanks for opening a pull request! If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project. Then could you also rename the pull request title in the following format? or See also: |
pitrou
left a comment
There was a problem hiding this comment.
This is looking promising @hadrian-reppas !
|
|
||
| void SetLogicalNullBits(const ArraySpan& span, uint8_t* out_bitmap, int64_t out_offset, | ||
| bool set_on_null) { | ||
| if (span.dictionary().GetNullCount() == 0 || span.length == 0) { |
There was a problem hiding this comment.
Using GetNullCount implies we're not looking up logical nulls in the dictionary values, only physical nulls, right?
This may be ok given that ArraySpan::ComputeLogicalNullCount does the same, but perhaps add a comment here?
There was a problem hiding this comment.
Yeah this feels kind of odd. I think we should probably be calling ComputeLogicalNullCount in both LogicalNullCount and SetLogicalNullBits.
There was a problem hiding this comment.
Actually, things become kind of messy if you look at logical nulls in the dictionary. Right now, it just looks at the dictionary validity bitmap. But if we wanted to properly handle logical nulls, we would need to deal with dictionaries that are dictionary, ree, and union types. So I'll keep this behavior for now and add a comment.
There was a problem hiding this comment.
I think you're right, also, dict_util::LogicalNullCount does not account for logical nulls in the dictionary either.
|
I just addressed your comments. Let me know what you think, @pitrou. |
|
(thanks a lot for the update btw, apart from the comment above it LGTM) |
Rationale for this change
I was looking into #49889 and updated the handling of logical nulls in the
is_valid,is_null, andtrue_unless_nullkernels. It turns out there is some prior work here that I didn't see before I starting implementing my fix (#35058, #35036, #37642). For some reason, that work has stalled.What changes are included in this PR?
This PR updates the
IsValidExec,IsNullExec, andTrueUnlessNullExeckernels so that they call out to a new functionSetLogicalNullBits. TheSetLogicalNullBitsfunction matches the logic inArraySpan::ComputeLogicalNullCount(). The logic is similar enough that they may be some opportunities for code deduplication indict_util.ccandree_util.cc.Are these changes tested?
Yes
Are there any user-facing changes?
No
true_unless_nullkernel output incorrect when run-end encoded array contains null #49889