Raise TypeError when indexing a dataset with bool
State: closed

Fix #5858.

Comments:
_The documentation is not available anymore as the PR was closed or merged._

@lhoestq any idea why this only fails (CI integration fails are unrelated) in "Build PR Documentation / build / build_pr_documentation" (which uses Python 3.8), with message:
```
TypeError: Type subscription requires python >= 3.9
```
whereas the CI is green for unit tests, which use Python 3.7?

Hmm I don't know sorry :/

@lhoestq I am afraid I have to remove the generics I created for numpy and pandas (no subscriptable until Python 3.9) and just leave:
```python
ListLike = Union[List[T], Tuple[T, ...]]
```

Ok sounds good - no need to spend more time on this

I will merge once the CI is finished. The integration errors are unrelated: `502 Server Error: Bad Gateway`

<details>
<summary>Show benchmarks</summary>

PyArrow==8.0.0

<details>
<summary>Show updated benchmarks!</summary>

### Benchmark: benchmark_array_xd.json

| metric | read_batch_formatted_as_numpy after write_array2d | read_batch_formatted_as_numpy after write_flattened_sequence | read_batch_formatted_as_numpy after write_nested_sequence | read_batch_unformated after write_array2d | read_batch_unformated after write_flattened_sequence | read_batch_unformated after write_nested_sequence | read_col_formatted_as_numpy after write_array2d | read_col_formatted_as_numpy after write_flattened_sequence | read_col_formatted_as_numpy after write_nested_sequence | read_col_unformated after write_array2d | read_col_unformated after write_flattened_sequence | read_col_unformated after write_nested_sequence | read_formatted_as_numpy after write_array2d | read_formatted_as_numpy after write_flattened_sequence | read_formatted_as_numpy after write_nested_sequence | read_unformated after write_array2d | read_unformated after write_flattened_sequence | read_unformated after write_nested_sequence | write_array2d | write_flattened_sequence | write_nested_sequence |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.006637 / 0.011353 (-0.004716) | 0.004578 / 0.011008 (-0.006430) | 0.097346 / 0.038508 (0.058838) | 0.034171 / 0.023109 (0.011062) | 0.315060 / 0.275898 (0.039162) | 0.354386 / 0.323480 (0.030907) | 0.005778 / 0.007986 (-0.002207) | 0.004123 / 0.004328 (-0.000206) | 0.073839 / 0.004250 (0.069589) | 0.046418 / 0.037052 (0.009366) | 0.325910 / 0.258489 (0.067421) | 0.368909 / 0.293841 (0.075068) | 0.027975 / 0.128546 (-0.100571) | 0.008885 / 0.075646 (-0.066761) | 0.327956 / 0.419271 (-0.091316) | 0.049911 / 0.043533 (0.006378) | 0.309424 / 0.255139 (0.054285) | 0.346543 / 0.283200 (0.063343) | 0.103429 / 0.141683 (-0.038253) | 1.517606 / 1.452155 (0.065451) | 1.536685 / 1.492716 (0.043969) |

### Benchmark: benchmark_getitem\_100B.json

| metric | get_batch_of\_1024\_random_rows | get_batch_of\_1024\_rows | get_first_row | get_last_row |
|--------|---|---|---|---|
| new / old (diff) | 0.211552 / 0.018006 (0.193546) | 0.449583 / 0.000490 (0.449094) | 0.002949 / 0.000200 (0.002750) | 0.000140 / 0.000054 (0.000086) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.027603 / 0.037411 (-0.009808) | 0.108873 / 0.014526 (0.094347) | 0.117990 / 0.176557 (-0.058567) | 0.174202 / 0.737135 (-0.562933) | 0.123793 / 0.296338 (-0.172545) |

### Benchmark: benchmark_iterating.json

| metric | read 5000 | read 50000 | read_batch 50000 10 | read_batch 50000 100 | read_batch 50000 1000 | read_formatted numpy 5000 | read_formatted pandas 5000 | read_formatted tensorflow 5000 | read_formatted torch 5000 | read_formatted_batch numpy 5000 10 | read_formatted_batch numpy 5000 1000 | shuffled read 5000 | shuffled read 50000 | shuffled read_batch 50000 10 | shuffled read_batch 50000 100 | shuffled read_batch 50000 1000 | shuffled read_formatted numpy 5000 | shuffled read_formatted_batch numpy 5000 10 | shuffled read_formatted_batch numpy 5000 1000 |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.418449 / 0.215209 (0.203240) | 4.177753 / 2.077655 (2.100099) | 1.923446 / 1.504120 (0.419326) | 1.720576 / 1.541195 (0.179381) | 1.783723 / 1.468490 (0.315232) | 0.530068 / 4.584777 (-4.054709) | 3.709410 / 3.745712 (-0.036302) | 1.863924 / 5.269862 (-3.405938) | 1.149906 / 4.565676 (-3.415770) | 0.066595 / 0.424275 (-0.357680) | 0.011733 / 0.007607 (0.004126) | 0.519249 / 0.226044 (0.293205) | 5.179676 / 2.268929 (2.910748) | 2.389488 / 55.444624 (-53.055137) | 2.060006 / 6.876477 (-4.816471) | 2.160668 / 2.142072 (0.018596) | 0.641081 / 4.805227 (-4.164146) | 0.141962 / 6.500664 (-6.358702) | 0.063146 / 0.075469 (-0.012323) |

### Benchmark: benchmark_map_filter.json

| metric | filter | map fast-tokenizer batched | map identity | map identity batched | map no-op batched | map no-op batched numpy | map no-op batched pandas | map no-op batched pytorch | map no-op batched tensorflow |
|--------|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 1.197424 / 1.841788 (-0.644364) | 14.915321 / 8.074308 (6.841013) | 14.792302 / 10.191392 (4.600910) | 0.145436 / 0.680424 (-0.534988) | 0.017669 / 0.534201 (-0.516532) | 0.399060 / 0.579283 (-0.180223) | 0.416282 / 0.434364 (-0.018082) | 0.498392 / 0.540337 (-0.041946) | 0.600242 / 1.386936 (-0.786694) |

</details>
PyArrow==latest

<details>
<summary>Show updated benchmarks!</summary>

### Benchmark: benchmark_array_xd.json

| metric | read_batch_formatted_as_numpy after write_array2d | read_batch_formatted_as_numpy after write_flattened_sequence | read_batch_formatted_as_numpy after write_nested_sequence | read_batch_unformated after write_array2d | read_batch_unformated after write_flattened_sequence | read_batch_unformated after write_nested_sequence | read_col_formatted_as_numpy after write_array2d | read_col_formatted_as_numpy after write_flattened_sequence | read_col_formatted_as_numpy after write_nested_sequence | read_col_unformated after write_array2d | read_col_unformated after write_flattened_sequence | read_col_unformated after write_nested_sequence | read_formatted_as_numpy after write_array2d | read_formatted_as_numpy after write_flattened_sequence | read_formatted_as_numpy after write_nested_sequence | read_unformated after write_array2d | read_unformated after write_flattened_sequence | read_unformated after write_nested_sequence | write_array2d | write_flattened_sequence | write_nested_sequence |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.007246 / 0.011353 (-0.004106) | 0.005353 / 0.011008 (-0.005656) | 0.076357 / 0.038508 (0.037849) | 0.037662 / 0.023109 (0.014553) | 0.387862 / 0.275898 (0.111964) | 0.421610 / 0.323480 (0.098130) | 0.006424 / 0.007986 (-0.001561) | 0.004397 / 0.004328 (0.000069) | 0.074212 / 0.004250 (0.069961) | 0.054147 / 0.037052 (0.017095) | 0.393171 / 0.258489 (0.134682) | 0.424082 / 0.293841 (0.130241) | 0.029001 / 0.128546 (-0.099546) | 0.009381 / 0.075646 (-0.066265) | 0.082562 / 0.419271 (-0.336710) | 0.048004 / 0.043533 (0.004472) | 0.386895 / 0.255139 (0.131756) | 0.386104 / 0.283200 (0.102904) | 0.113714 / 0.141683 (-0.027969) | 1.435601 / 1.452155 (-0.016553) | 1.554940 / 1.492716 (0.062224) |

### Benchmark: benchmark_getitem\_100B.json

| metric | get_batch_of\_1024\_random_rows | get_batch_of\_1024\_rows | get_first_row | get_last_row |
|--------|---|---|---|---|
| new / old (diff) | 0.179288 / 0.018006 (0.161282) | 0.455301 / 0.000490 (0.454811) | 0.001469 / 0.000200 (0.001269) | 0.000091 / 0.000054 (0.000036) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.030928 / 0.037411 (-0.006484) | 0.117833 / 0.014526 (0.103307) | 0.125088 / 0.176557 (-0.051468) | 0.178906 / 0.737135 (-0.558230) | 0.131264 / 0.296338 (-0.165075) |

### Benchmark: benchmark_iterating.json

| metric | read 5000 | read 50000 | read_batch 50000 10 | read_batch 50000 100 | read_batch 50000 1000 | read_formatted numpy 5000 | read_formatted pandas 5000 | read_formatted tensorflow 5000 | read_formatted torch 5000 | read_formatted_batch numpy 5000 10 | read_formatted_batch numpy 5000 1000 | shuffled read 5000 | shuffled read 50000 | shuffled read_batch 50000 10 | shuffled read_batch 50000 100 | shuffled read_batch 50000 1000 | shuffled read_formatted numpy 5000 | shuffled read_formatted_batch numpy 5000 10 | shuffled read_formatted_batch numpy 5000 1000 |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.436900 / 0.215209 (0.221691) | 4.366094 / 2.077655 (2.288439) | 2.184398 / 1.504120 (0.680278) | 1.992779 / 1.541195 (0.451584) | 2.055260 / 1.468490 (0.586770) | 0.524136 / 4.584777 (-4.060641) | 3.750535 / 3.745712 (0.004823) | 2.985095 / 5.269862 (-2.284767) | 1.400291 / 4.565676 (-3.165385) | 0.065921 / 0.424275 (-0.358354) | 0.012110 / 0.007607 (0.004502) | 0.538239 / 0.226044 (0.312195) | 5.380613 / 2.268929 (3.111685) | 2.637509 / 55.444624 (-52.807116) | 2.352265 / 6.876477 (-4.524212) | 2.409829 / 2.142072 (0.267756) | 0.640428 / 4.805227 (-4.164799) | 0.142070 / 6.500664 (-6.358594) | 0.068171 / 0.075469 (-0.007298) |

### Benchmark: benchmark_map_filter.json

| metric | filter | map fast-tokenizer batched | map identity | map identity batched | map no-op batched | map no-op batched numpy | map no-op batched pandas | map no-op batched pytorch | map no-op batched tensorflow |
|--------|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 1.280080 / 1.841788 (-0.561707) | 15.588799 / 8.074308 (7.514491) | 14.648596 / 10.191392 (4.457204) | 0.147027 / 0.680424 (-0.533397) | 0.018981 / 0.534201 (-0.515220) | 0.394796 / 0.579283 (-0.184487) | 0.423686 / 0.434364 (-0.010678) | 0.467376 / 0.540337 (-0.072961) | 0.562247 / 1.386936 (-0.824689) |

</details>
</details>

![](https://cml.dev/watermark.png#680162303f4c5dae6ad2edef6b3efadded7d37bd "CML watermark")