taepper opened a new issue, #51210:
URL: https://github.com/apache/arrow/issues/51210

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   If an input `Table` or `ChunkedArray` is empty, the `SelectKthInternal` 
function have the following early return:
   
   ```
         if (num_rows == 0) {                                                   
                                                                                
                                       
           return Status::OK();                                                 
                                                                                
                                    
         }                                                                      
                                                                                
                                         
   ```
   
   Crucially, `output_` is never set in these cases. Therefore, 
`SelectKUnstable`'s `make_array()` call:
   ```
     Result<std::shared_ptr<Array>> SelectKUnstable(const Datum& datum, ...) {  
                      
       ARROW_ASSIGN_OR_RAISE(Datum result,                                      
                      
                             CallFunction("select_k_unstable", {datum}, 
&options, ctx));               
       return result.make_array();
     }                                                                          
                       
   ```
   
   will fail this `DCHECK_EQ`:
   ```
     std::shared_ptr<Array> Datum::make_array() const {                         
                                                                                
                                         
       DCHECK_EQ(Datum::ARRAY, this->kind());
       return MakeArray(std::get<std::shared_ptr<ArrayData>>(this->value));     
                                       
     }                                                                          
                                                                                
                                  
   ```
   
   This can also be reproduced in python code by calling `select_k_unstable` 
with an empty `ChunkedArray` or `Table` respectively
   
   ### Component(s)
   
   C++


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