| 3060 | |
| 3061 | |
| 3062 | def test_count_sparse_union_sliced_nulls(): |
| 3063 | # GH-50113: Sliced unions can report incorrect null counts in count. |
| 3064 | arr = pa.UnionArray.from_sparse( |
| 3065 | pa.array([0, 1, 0, 0, 1, 1], type=pa.int8()), |
| 3066 | [ |
| 3067 | pa.array([0.5, 99.0, None, 3.0, 88.0, 77.0]), |
| 3068 | pa.array([False, None, True, False, True, False]), |
| 3069 | ] |
| 3070 | ) |
| 3071 | |
| 3072 | # Logical array: [0.5, None, None, 3.0, True, False]. |
| 3073 | assert pc.count(arr, mode="only_valid").as_py() == 4 |
| 3074 | assert pc.count(arr, mode="only_null").as_py() == 2 |
| 3075 | assert pc.count(arr, mode="all").as_py() == 6 |
| 3076 | # Logical slice: [None, None, 3.0, True]. |
| 3077 | assert pc.count(arr.slice(1, 4), mode="only_valid").as_py() == 2 |
| 3078 | assert pc.count(arr.slice(1, 4), mode="only_null").as_py() == 2 |
| 3079 | |
| 3080 | |
| 3081 | def test_count_dense_union_sliced_nulls(): |