pitrou commented on code in PR #41975:
URL: https://github.com/apache/arrow/pull/41975#discussion_r1653237808


##########
cpp/src/arrow/compute/exec.cc:
##########
@@ -498,15 +510,37 @@ struct NullGeneralization {
     return PERHAPS_NULL;
   }
 
+  static type Get(const ChunkedArray& chunk_array) {
+    if (chunk_array.num_chunks() == 0) {
+      return ALL_VALID;
+    }
+    if (chunk_array.null_count() == chunk_array.length()) {

Review Comment:
   This does not follow the same constraint as Array above: _"Do not count the 
bits if they haven't been counted already"_.
   
   I think you should instead just iterate on the chunks, such as (untested):
   ```c++
     static type Get(const ArraySpan& array) {
       // Do not count the bits if they haven't been counted already
       if ((arr.null_count == 0) || (arr.buffers[0].data == nullptr)) {
         return ALL_VALID;
       }
       if (arr.null_count == arr.length) {
         return ALL_NULL;
       }
       return PERHAPS_NULL;
     }
   
     static type Get(const ChunkedArray& chunk_array) {
       std::optional<type> current_gen;
       for (const auto& chunk : chunk_array.chunks()) {
         if (chunk->length() == 0) {
           continue;
         }
         chunk_gen = Get(*chunk);
         if (current_gen.has_value() && chunk_gen != *current_gen) {
           return PERHAPS_NULL;
         }
         current_gen = chunk_gen;
       }
       return current_gen.value_or(ALL_VALID);
     }
   ```



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