Title: Fix parquet columns argument in streaming mode
Author: lhoestq (MEMBER)
State: closed
Created: 2023-10-11T10:01:01Z

It was failing when there's a DatasetInfo with non-None info.features from the YAML (therefore containing columns that should be ignored)

Fix https://github.com/huggingface/datasets/issues/6293

Comments:
<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.008112 / 0.011353 (-0.003241) | 0.004762 / 0.011008 (-0.006247) | 0.101349 / 0.038508 (0.062841) | 0.092361 / 0.023109 (0.069252) | 0.418429 / 0.275898 (0.142531) | 0.427332 / 0.323480 (0.103852) | 0.006112 / 0.007986 (-0.001874) | 0.003920 / 0.004328 (-0.000408) | 0.076813 / 0.004250 (0.072563) | 0.064361 / 0.037052 (0.027309) | 0.420526 / 0.258489 (0.162037) | 0.441576 / 0.293841 (0.147735) | 0.044760 / 0.128546 (-0.083787) | 0.010054 / 0.075646 (-0.065592) | 0.346063 / 0.419271 (-0.073209) | 0.077453 / 0.043533 (0.033920) | 0.412871 / 0.255139 (0.157732) | 0.408307 / 0.283200 (0.125107) | 0.033398 / 0.141683 (-0.108285) | 1.755825 / 1.452155 (0.303671) | 1.852347 / 1.492716 (0.359630) |

### 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.274201 / 0.018006 (0.256194) | 0.536375 / 0.000490 (0.535885) | 0.008076 / 0.000200 (0.007876) | 0.000159 / 0.000054 (0.000105) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.033567 / 0.037411 (-0.003845) | 0.102378 / 0.014526 (0.087852) | 0.114176 / 0.176557 (-0.062381) | 0.180576 / 0.737135 (-0.556560) | 0.114801 / 0.296338 (-0.181538) |

### 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.450300 / 0.215209 (0.235091) | 4.490940 / 2.077655 (2.413285) | 2.172412 / 1.504120 (0.668292) | 1.978746 / 1.541195 (0.437551) | 2.065602 / 1.468490 (0.597112) | 0.571260 / 4.584777 (-4.013517) | 4.185485 / 3.745712 (0.439773) | 3.885594 / 5.269862 (-1.384268) | 2.532942 / 4.565676 (-2.032735) | 0.067612 / 0.424275 (-0.356663) | 0.008694 / 0.007607 (0.001087) | 0.533375 / 0.226044 (0.307331) | 5.321261 / 2.268929 (3.052333) | 2.697788 / 55.444624 (-52.746836) | 2.331328 / 6.876477 (-4.545149) | 2.585168 / 2.142072 (0.443096) | 0.681760 / 4.805227 (-4.123467) | 0.157687 / 6.500664 (-6.342977) | 0.071014 / 0.075469 (-0.004455) |

### 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.525689 / 1.841788 (-0.316098) | 23.162280 / 8.074308 (15.087972) | 16.644941 / 10.191392 (6.453548) | 0.182588 / 0.680424 (-0.497836) | 0.021653 / 0.534201 (-0.512548) | 0.466556 / 0.579283 (-0.112727) | 0.511902 / 0.434364 (0.077538) | 0.553707 / 0.540337 (0.013370) | 0.777830 / 1.386936 (-0.609106) |

</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.007954 / 0.011353 (-0.003399) | 0.004645 / 0.011008 (-0.006363) | 0.079096 / 0.038508 (0.040587) | 0.088200 / 0.023109 (0.065090) | 0.508882 / 0.275898 (0.232984) | 0.545986 / 0.323480 (0.222506) | 0.006233 / 0.007986 (-0.001752) | 0.004016 / 0.004328 (-0.000312) | 0.078103 / 0.004250 (0.073853) | 0.066354 / 0.037052 (0.029302) | 0.504132 / 0.258489 (0.245643) | 0.543714 / 0.293841 (0.249873) | 0.038140 / 0.128546 (-0.090407) | 0.011201 / 0.075646 (-0.064446) | 0.085713 / 0.419271 (-0.333559) | 0.057169 / 0.043533 (0.013637) | 0.488161 / 0.255139 (0.233022) | 0.516231 / 0.283200 (0.233031) | 0.027868 / 0.141683 (-0.113814) | 1.794084 / 1.452155 (0.341930) | 1.884993 / 1.492716 (0.392276) |

### 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.263108 / 0.018006 (0.245102) | 0.495761 / 0.000490 (0.495272) | 0.007056 / 0.000200 (0.006856) | 0.000117 / 0.000054 (0.000062) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.039089 / 0.037411 (0.001678) | 0.113332 / 0.014526 (0.098806) | 0.130137 / 0.176557 (-0.046419) | 0.189330 / 0.737135 (-0.547805) | 0.125860 / 0.296338 (-0.170479) |

### 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.530496 / 0.215209 (0.315287) | 5.349235 / 2.077655 (3.271581) | 2.975886 / 1.504120 (1.471766) | 2.786368 / 1.541195 (1.245173) | 2.920448 / 1.468490 (1.451958) | 0.575677 / 4.584777 (-4.009100) | 4.215535 / 3.745712 (0.469823) | 3.879984 / 5.269862 (-1.389878) | 2.420193 / 4.565676 (-2.145484) | 0.068506 / 0.424275 (-0.355769) | 0.008785 / 0.007607 (0.001178) | 0.611471 / 0.226044 (0.385427) | 6.118399 / 2.268929 (3.849471) | 3.509376 / 55.444624 (-51.935248) | 3.149219 / 6.876477 (-3.727257) | 3.413861 / 2.142072 (1.271788) | 0.697586 / 4.805227 (-4.107641) | 0.157767 / 6.500664 (-6.342897) | 0.071539 / 0.075469 (-0.003930) |

### 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.625196 / 1.841788 (-0.216591) | 24.347319 / 8.074308 (16.273011) | 17.365789 / 10.191392 (7.174397) | 0.217590 / 0.680424 (-0.462834) | 0.023885 / 0.534201 (-0.510316) | 0.477226 / 0.579283 (-0.102057) | 0.529319 / 0.434364 (0.094955) | 0.622299 / 0.540337 (0.081962) | 0.835295 / 1.386936 (-0.551641) |

</details>
</details>

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


CI errors are unrelated or due to flaky tests

<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.006288 / 0.011353 (-0.005065) | 0.003836 / 0.011008 (-0.007172) | 0.080958 / 0.038508 (0.042450) | 0.065934 / 0.023109 (0.042825) | 0.312597 / 0.275898 (0.036699) | 0.351216 / 0.323480 (0.027736) | 0.004864 / 0.007986 (-0.003121) | 0.002961 / 0.004328 (-0.001368) | 0.063142 / 0.004250 (0.058892) | 0.049822 / 0.037052 (0.012770) | 0.320305 / 0.258489 (0.061816) | 0.363151 / 0.293841 (0.069310) | 0.027561 / 0.128546 (-0.100985) | 0.008176 / 0.075646 (-0.067470) | 0.261290 / 0.419271 (-0.157982) | 0.045517 / 0.043533 (0.001984) | 0.309218 / 0.255139 (0.054079) | 0.340140 / 0.283200 (0.056940) | 0.021000 / 0.141683 (-0.120683) | 1.448699 / 1.452155 (-0.003456) | 1.523904 / 1.492716 (0.031188) |

### 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.224294 / 0.018006 (0.206288) | 0.434928 / 0.000490 (0.434439) | 0.007541 / 0.000200 (0.007341) | 0.000286 / 0.000054 (0.000232) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.025257 / 0.037411 (-0.012154) | 0.077364 / 0.014526 (0.062838) | 0.085825 / 0.176557 (-0.090732) | 0.148121 / 0.737135 (-0.589014) | 0.086838 / 0.296338 (-0.209500) |

### 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.396900 / 0.215209 (0.181691) | 3.953381 / 2.077655 (1.875727) | 1.933561 / 1.504120 (0.429441) | 1.760549 / 1.541195 (0.219354) | 1.824014 / 1.468490 (0.355523) | 0.495385 / 4.584777 (-4.089392) | 3.005558 / 3.745712 (-0.740154) | 2.931022 / 5.269862 (-2.338840) | 1.905113 / 4.565676 (-2.660563) | 0.057232 / 0.424275 (-0.367043) | 0.006472 / 0.007607 (-0.001135) | 0.464261 / 0.226044 (0.238216) | 4.629388 / 2.268929 (2.360459) | 2.342004 / 55.444624 (-53.102620) | 1.977295 / 6.876477 (-4.899181) | 2.167151 / 2.142072 (0.025079) | 0.582483 / 4.805227 (-4.222744) | 0.129444 / 6.500664 (-6.371220) | 0.061057 / 0.075469 (-0.014412) |

### 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.259444 / 1.841788 (-0.582344) | 18.189338 / 8.074308 (10.115030) | 14.313174 / 10.191392 (4.121782) | 0.146209 / 0.680424 (-0.534215) | 0.017115 / 0.534201 (-0.517086) | 0.336643 / 0.579283 (-0.242640) | 0.370824 / 0.434364 (-0.063540) | 0.387032 / 0.540337 (-0.153306) | 0.546688 / 1.386936 (-0.840248) |

</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.006371 / 0.011353 (-0.004982) | 0.003693 / 0.011008 (-0.007315) | 0.062499 / 0.038508 (0.023991) | 0.066367 / 0.023109 (0.043257) | 0.451481 / 0.275898 (0.175583) | 0.482495 / 0.323480 (0.159015) | 0.005676 / 0.007986 (-0.002310) | 0.002940 / 0.004328 (-0.001389) | 0.063011 / 0.004250 (0.058760) | 0.051500 / 0.037052 (0.014447) | 0.455482 / 0.258489 (0.196993) | 0.488888 / 0.293841 (0.195047) | 0.028714 / 0.128546 (-0.099832) | 0.008178 / 0.075646 (-0.067468) | 0.067218 / 0.419271 (-0.352053) | 0.041323 / 0.043533 (-0.002210) | 0.454007 / 0.255139 (0.198868) | 0.476241 / 0.283200 (0.193041) | 0.021530 / 0.141683 (-0.120153) | 1.457859 / 1.452155 (0.005705) | 1.506437 / 1.492716 (0.013721) |

### 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.228280 / 0.018006 (0.210274) | 0.427574 / 0.000490 (0.427084) | 0.003793 / 0.000200 (0.003593) | 0.000076 / 0.000054 (0.000022) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.028420 / 0.037411 (-0.008992) | 0.087935 / 0.014526 (0.073409) | 0.092761 / 0.176557 (-0.083796) | 0.148084 / 0.737135 (-0.589051) | 0.095301 / 0.296338 (-0.201037) |

### 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.462457 / 0.215209 (0.247248) | 4.618016 / 2.077655 (2.540361) | 2.540531 / 1.504120 (1.036412) | 2.384696 / 1.541195 (0.843501) | 2.493108 / 1.468490 (1.024618) | 0.511689 / 4.584777 (-4.073088) | 3.173701 / 3.745712 (-0.572011) | 2.917046 / 5.269862 (-2.352816) | 1.916294 / 4.565676 (-2.649382) | 0.058969 / 0.424275 (-0.365306) | 0.006461 / 0.007607 (-0.001147) | 0.540997 / 0.226044 (0.314952) | 5.406596 / 2.268929 (3.137667) | 3.071189 / 55.444624 (-52.373435) | 2.701982 / 6.876477 (-4.174494) | 2.860194 / 2.142072 (0.718121) | 0.602684 / 4.805227 (-4.202543) | 0.127384 / 6.500664 (-6.373280) | 0.061718 / 0.075469 (-0.013751) |

### 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.340587 / 1.841788 (-0.501201) | 18.543831 / 8.074308 (10.469523) | 14.847319 / 10.191392 (4.655927) | 0.146523 / 0.680424 (-0.533901) | 0.018172 / 0.534201 (-0.516029) | 0.333276 / 0.579283 (-0.246007) | 0.375874 / 0.434364 (-0.058490) | 0.396766 / 0.540337 (-0.143572) | 0.572562 / 1.386936 (-0.814374) |

</details>
</details>

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