| 2131 | |
| 2132 | @pytest.mark.parametrize('arrow_type', numerical_arrow_types) |
| 2133 | def test_fill_null_array(arrow_type): |
| 2134 | arr = pa.array([1, 2, None, 4], type=arrow_type) |
| 2135 | fill_value = pa.scalar(5, type=arrow_type) |
| 2136 | result = arr.fill_null(fill_value) |
| 2137 | expected = pa.array([1, 2, 5, 4], type=arrow_type) |
| 2138 | assert result.equals(expected) |
| 2139 | |
| 2140 | # Implicit conversions |
| 2141 | result = arr.fill_null(5) |
| 2142 | assert result.equals(expected) |
| 2143 | |
| 2144 | # ARROW-9451: Unsigned integers allow this for some reason |
| 2145 | if not pa.types.is_unsigned_integer(arr.type): |
| 2146 | with pytest.raises((ValueError, TypeError)): |
| 2147 | arr.fill_null('5') |
| 2148 | |
| 2149 | result = arr.fill_null(pa.scalar(5, type='int8')) |
| 2150 | assert result.equals(expected) |
| 2151 | |
| 2152 | |
| 2153 | @pytest.mark.parametrize('arrow_type', numerical_arrow_types) |