Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-14156

[C++] StructArray::Flatten is incorrect in some cases

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.0.0
    • 6.0.0
    • C++

    Description

      When trying to flatten a struct that has children that were sliced we see incorrect results.

       

      Bar.java
      import pyarrow as pa
      
      a = py.array([1,2,3])
      
      sliceds = a.slice(1)
      
      composed_struct = pa.StructArray.from_buffers(pa.struct([pa.field("a", sliceds.type)]), len(sliceds), [pa.array([True, False]).buffers()[1]], children=[sliceds])
      
      >>> composed_struct
      <pyarrow.lib.StructArray object at 0x7f5502a74880>
      -- is_valid:
        [
          true,
          false
        ]
      
      -- child 0 type: int64
        [
          2,
          3
        ]
      
      >>> composed_struct.flatten()
      [<pyarrow.lib.Int64Array object at 0x7f5502a74460>
      [
        null,
        null
      ]]
      

       
      I believe the problems is here the copy does not account for child array offset.

      Attachments

        Issue Links

          Activity

            People

              lidavidm David Li
              emkornfield Micah Kornfield
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m