apache / apache/arrow

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

Open
#30,954 1 comment 0 reactions 0 assignees View on GitHub
Component: C++ Type: enhancement
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

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:

```python

>>> typ = pa.list_(pa.field("element", pa.int64(), nullable=False))
>>> arr = pa.array([[1, 2], [3, 4, None]], typ)
>>> arr

[
[
1,
2
],
[
3,
4,
null
]
]

>>> arr.type
ListType(list)
```

Also explicitly validating it doesn't raise:

```python

>>> 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](https://issues.apache.org/jira/browse/ARROW-15478) / @jorisvandenbossche
#### Related issues:
- [[Python] Casting Table to new schema ignores nullability of fields](https://github.com/apache/arrow/issues/32000) (relates to)

**Note**: *This issue was originally created as [ARROW-15478](https://issues.apache.org/jira/browse/ARROW-15478). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Python examples using pa.list_, pa.array, and ListArray.validate(full=True). Read the related issue about casting tables to a new schema and determine the intended guarantees for nullability in nested fields. Done means the nullability behavior is specified and covered by appropriate regression tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
data-engineering
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.