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

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   **Describe the bug, including details regarding any error messages, version, 
and platform.**
   
   When attempting to use ` arrow::StructArray::Make` to nest fields in our 
example below, we find our "Hour" and "Minute" fields are turned into "child 0" 
and "child 1" respectively.
   
   ```cpp
   #include <arrow/api.h>
   #include <iostream>
   
   arrow::Status RunTest()
   {
       // Sample Data
       int16_t hours[2][1] = { { 9 }, { 8 } };
       int16_t minutes[2][1] = { { 3 }, { 45 } };
       int16_t days[2] = { 1, 2 };
   
       // Create Field Vector for Struct Array
       const arrow::FieldVector f_time = { arrow::field( "Hour", arrow::int16() 
),
                                           arrow::field( "Minute", 
arrow::int16() ) };
   
       // Create Arrays an StructArray
       std::shared_ptr< arrow::Array > v_hours;
       std::shared_ptr< arrow::Array > v_minutes;
       std::shared_ptr< arrow::Array > v_days;
       std::shared_ptr< arrow::StructArray > v_timestamp;
   
       // Build Arrays and Struct Array
       arrow::Int16Builder builder;
       ARROW_RETURN_NOT_OK( builder.AppendValues( hours[0], 1 ) );
       ARROW_RETURN_NOT_OK( builder.AppendValues( hours[1], 1 ) );
       ARROW_ASSIGN_OR_RAISE( v_hours, builder.Finish() );
   
       ARROW_RETURN_NOT_OK( builder.AppendValues( minutes[0], 1 ) );
       ARROW_RETURN_NOT_OK( builder.AppendValues( minutes[1], 1 ) );
       ARROW_ASSIGN_OR_RAISE( v_minutes, builder.Finish() );
   
       ARROW_ASSIGN_OR_RAISE( v_timestamp, arrow::StructArray::Make( { v_hours, 
v_minutes }, f_time ) );
   
       ARROW_RETURN_NOT_OK( builder.AppendValues( days, 2 ) );
       ARROW_ASSIGN_OR_RAISE( v_days, builder.Finish() );
   
       // Create Schema
       std::shared_ptr< arrow::Field > f_days = arrow::field( "Day", 
arrow::int16() );
       std::shared_ptr< arrow::Field > f_timestamp = arrow::field( "Timestamp", 
arrow::int16() );
   
       auto schema = arrow::schema( { f_days, f_timestamp } );
   
       // Create Record Batch
       auto rbatch = arrow::RecordBatch::Make( schema, 2, { v_days, v_timestamp 
} );
   
       // Print Record Batch
       std::cout << rbatch->ToString();
   
       return arrow::Status::OK();
   }
   
   int main()
   {
       
       arrow::Status st = RunTest();
       if ( !st.ok() )
       {
           std::cerr << st << std::endl;
           return 1;
       }
       return 0;
   }
   ```
   
   The output yields
   ```sh
   Day:   [
       1,
       2
     ]
   Timestamp:   -- is_valid: all not null
     -- child 0 type: int16
       [
         9,
         8
       ]
     -- child 1 type: int16
       [
         3,
         45
       ]
   ```
   
   **Expected Results**
   ```sh
   Day:   [
       1,
       2
     ]
   Timestamp:   -- is_valid: all not null
     -- Hour type: int16
       [
         9,
         8
       ]
     -- Minute type: int16
       [
         3,
         45
       ]
   ```
   
   **Any error messages, version, and platform.**
   
   No error messages or warnings were received.
   
   **Version and Platform**
   
   Version of Arrow: 20.0.0
   
   `lsb_release -a`
   
   ```sh
   No LSB modules are available.
   Distributor ID: Ubuntu
   Description:    Ubuntu 24.04.2 LTS
   Release:        24.04
   Codename:       noble
   ```
   
   Linux Kernel: 6.8.0-48-generic
   
   `uname -m`
   
   ```sh
   x86_64
   ```
   
   
   ### 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