Skip to content

[C++] Creating (or casting to) list array with non-nullable field doesn't check nulls #30954

@asfimport

Description

@asfimport

When creating a ListArray where you indicate that the values field is not nullable, you can actually create the array with nulls without this is being validated:

>>> typ = pa.list_(pa.field("element", pa.int64(), nullable=False))
>>> arr = pa.array([[1, 2], [3, 4, None]], typ)
>>> arr
<pyarrow.lib.ListArray object at 0x7f75bdeba760>
[
  [
    1,
    2
  ],
  [
    3,
    4,
    null
  ]
]

>>> arr.type
ListType(list<element: int64 not null>)

Also explicitly validating it doesn't raise:

>>> arr.validate(full=True)

Is this something we should check?
What guarantees do we attach to the nullability of a field of a nested type?

Reporter: Joris Van den Bossche / @jorisvandenbossche

Related issues:

Note: This issue was originally created as ARROW-15478. Please see the migration documentation for further details.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions