Error of writing with different schema, due to nonpreservation of nullability
{'login': 'richarddwang', 'id': 17963619, 'node_id': 'MDQ6VXNlcjE3OTYzNjE5', 'avatar_url': 'https://avatars.githubusercontent.com/u/17963619?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/richarddwang', 'html_url': 'https://github.com/richarddwang', 'followers_url': 'https://api.github.com/users/richarddwang/followers', 'following_url': 'https://api.github.com/users/richarddwang/following{/other_user}', 'gists_url': 'https://api.github.com/users/richarddwang/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/richarddwang/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/richarddwang/subscriptions', 'organizations_url': 'https://api.github.com/users/richarddwang/orgs', 'repos_url': 'https://api.github.com/users/richarddwang/repos', 'events_url': 'https://api.github.com/users/richarddwang/events{/privacy}', 'received_events_url': 'https://api.github.com/users/richarddwang/received_events', 'type': 'User', 'site_admin': False}
[]
[]
["Hi ! Thanks for reporting, indeed `disable_nullable` doesn't seem to be supported in this case. Maybe at one point we can have `disable_nullable` as a parameter of certain feature types"]
{'url': 'https://api.github.com/repos/huggingface/datasets/pulls/3782', 'html_url': 'https://github.com/huggingface/datasets/pull/3782', 'diff_url': 'https://github.com/huggingface/datasets/pull/3782.diff', 'patch_url': 'https://github.com/huggingface/datasets/pull/3782.patch', 'merged_at': datetime.datetime(2022, 3, 3, 14, 54, 39)}
## 1. Case
```
dataset.map(
  batched=True,
  disable_nullable=True,
)
```
will get the following error at here https://github.com/huggingface/datasets/blob/c9967f55626931f8059dc416526c791444cdfdf7/src/datasets/arrow_writer.py#L516

`pyarrow.lib.ArrowInvalid: Tried to write record batch with different schema`

## 2. Debugging
### 2.1 tracing
During `_map_single`, the following are called
https://github.com/huggingface/datasets/blob/c9967f55626931f8059dc416526c791444cdfdf7/src/datasets/arrow_dataset.py#L2523
https://github.com/huggingface/datasets/blob/c9967f55626931f8059dc416526c791444cdfdf7/src/datasets/arrow_writer.py#L511
### 2.2. Observation
The problem is, even after `table_cast`, `pa_table.schema != self._schema`
`pa_table.schema` (before/after `table_cast`)
```
input_ids: list<item: int32>
  child 0, item: int32
```
`self._schema`
```
input_ids: list<item: int32> not null
  child 0, item: int32
```
### 2.3. Reason
https://github.com/huggingface/datasets/blob/c9967f55626931f8059dc416526c791444cdfdf7/src/datasets/table.py#L1121
Here we lose nullability stored in `schema` because it seems that `Features` is always nullable and don't store nullability.
https://github.com/huggingface/datasets/blob/c9967f55626931f8059dc416526c791444cdfdf7/src/datasets/table.py#L1103
So, casting to schema from such `Features` loses nullability, and eventually causes error of writing with different schema

## 3. Solution
1. Let `Features` stores nullability.
2. Directly cast table with original schema but not schema from converted `Features`. (this PR)
3. Don't `cast_table` when `write_table`
{'url': 'https://api.github.com/repos/huggingface/datasets/issues/3782/reactions', 'total_count': 0, '+1': 0, '-1': 0, 'laugh': 0, 'hooray': 0, 'confused': 0, 'heart': 0, 'rocket': 0, 'eyes': 0}