You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Micah Kornfield (Jira)" <ji...@apache.org> on 2021/09/28 16:57:00 UTC

[jira] [Created] (ARROW-14156) StructArray::Flatten is incorrect in some cases

Micah Kornfield created ARROW-14156:
---------------------------------------

             Summary: StructArray::Flatten is incorrect in some cases
                 Key: ARROW-14156
                 URL: https://issues.apache.org/jira/browse/ARROW-14156
             Project: Apache Arrow
          Issue Type: Bug
          Components: C++
    Affects Versions: 5.0.0
            Reporter: Micah Kornfield


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

 
{code:title=Bar.java|borderStyle=solid}
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
]]
{code}
 
I believe the problems is [here|https://github.com/apache/arrow/blob/8e43f23dcc6a9e630516228f110c48b64d13cec6/cpp/src/arrow/array/array_nested.cc#L572] the copy does not account for child array offset.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)