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

   ### Describe the usage question you have. Please include as many useful 
details as  possible.
   
   
   I use Compute Function according to the example on the official website, and 
can compile successfully, but in the execution is an error: Key error: No 
function registered with name: sum
   Here's my code:
   
   #include <iostream>
   #include <arrow/api.h>
   #include <arrow/compute/api.h>
   
   using namespace std;
   
   arrow::Status RunMain() {
       // Create a couple 32-bit integer arrays.
       arrow::Int32Builder int32builder;
       int32_t some_nums_raw[5] = {34, 624, 2223, 5654, 4356};
       ARROW_RETURN_NOT_OK(int32builder.AppendValues(some_nums_raw, 5));
       std::shared_ptr<arrow::Array> some_nums;
       ARROW_ASSIGN_OR_RAISE(some_nums, int32builder.Finish());
   
       int32_t more_nums_raw[5] = {75342, 23, 64, 17, 736};
       ARROW_RETURN_NOT_OK(int32builder.AppendValues(more_nums_raw, 5));
       std::shared_ptr<arrow::Array> more_nums;
       ARROW_ASSIGN_OR_RAISE(more_nums, int32builder.Finish());
   
       // Make a table out of our pair of arrays.
       std::shared_ptr<arrow::Field> field_a, field_b;
       std::shared_ptr<arrow::Schema> schema;
   
       field_a = arrow::field("A", arrow::int32());
       field_b = arrow::field("B", arrow::int32());
   
       schema = arrow::schema({field_a, field_b});
   
       std::shared_ptr<arrow::Table> table;
       table = arrow::Table::Make(schema, {some_nums, more_nums}, 5);
       
       arrow::Datum tmp;
       ARROW_ASSIGN_OR_RAISE(tmp, 
arrow::compute::Sum({table->GetColumnByName("A")}));
       // Get the kind of Datum and what it holds -- this is a Scalar, with 
int64.
       std::cout << "Datum kind: " << tmp.ToString() << " content type: " << 
tmp.type()->ToString() << std::endl;
       std::cout << tmp.scalar_as<arrow::Int64Scalar>().value << std::endl;
   
       return arrow::Status::OK();
   }
   
   int main() {
      arrow::Status st = RunMain();
       if (!st.ok()) {
           std::cerr << st << std::endl;
           return 1;
       }
       return 0;
   }
   
   
   ### 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: issues-unsubscr...@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to