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

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   Here is my code:
   `#include <iostream>
   #include <arrow/api.h>
   #include <arrow/compute/api.h>
   #include <arrow/array.h>
   
   using namespace std;
   
   arrow::Status RunMain() {
     // row {day, month, year}
     arrow::Int8Builder int8builder;
     int8_t days_raw[5] = {1, 17, 12, 28, 21};
     ARROW_RETURN_NOT_OK(int8builder.AppendValues(days_raw, 5));
     std::shared_ptr<arrow::Array> days;
     ARROW_ASSIGN_OR_RAISE(days, int8builder.Finish());
   
     arrow::Int16Builder int16builder;
     int16_t months_raw[5] = {1, 3, 5, 7, 1};
     ARROW_RETURN_NOT_OK(int16builder.AppendValues(months_raw, 5));
     std::shared_ptr<arrow::Array> months;
     ARROW_ASSIGN_OR_RAISE(months, int16builder.Finish());
   
     arrow::Int32Builder int32builder;
     int32_t years_raw[5] = {1990, 2000, 1995, 2000, 1995};
     ARROW_RETURN_NOT_OK(int32builder.AppendValues(years_raw, 5));
     std::shared_ptr<arrow::Array> years;
     ARROW_ASSIGN_OR_RAISE(years, int32builder.Finish());
   
     std::shared_ptr<arrow::Field> field_day, field_month, field_year;
     std::shared_ptr<arrow::Schema> schema;
     field_day = arrow::field("Day", arrow::int8());
     field_month = arrow::field("Month", arrow::int16());
     field_year = arrow::field("Year", arrow::int32());
     schema = arrow::schema({field_day, field_month, field_year});
     std::shared_ptr<arrow::RecordBatch> rbatch;
     rbatch = arrow::RecordBatch::Make(schema, days->length(), {days, months, 
years});
   
     auto day_int8_array = 
std::static_pointer_cast<arrow::Int8Array>(rbatch->column(0));
     auto month_int16_array = 
std::static_pointer_cast<arrow::Int16Array>(rbatch->column(1));
     auto year_int32_array = 
std::static_pointer_cast<arrow::Int32Array>(rbatch->column(2));
     for(int64_t i = 0; i < rbatch->column(0)->length(); ++i) {
       std::cout << "[day, month, year] :" <<"[" << day_int8_array->Value(i) << 
", " << month_int16_array->Value(i) << ", " << year_int32_array->Value(i) << 
"]" << std::endl;
     }
     return arrow::Status::OK();
   }
   
   int main() {
      arrow::Status st = RunMain();
       if (!st.ok()) {
           std::cerr << st << std::endl;
           return 1;
       }
       return 0;
   }
   `
   Running result:
   
![bug1](https://github.com/apache/arrow/assets/22023446/27214ecd-3956-41fe-97da-0c8ae7c6722f)
   Conversion is correct for Int16Array and Int32Array types, only the output 
result for Int8Array is incorrect.
   
   ### 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