Function load_dataset() misinterprets string field content as part of dataset schema when dealing with `.jsonl` files
NONE
Somehow I created the issue twice🙈 This one is an exact duplicate of #7664.
2025-07-01T17:17:31Z
https://github.com/huggingface/datasets/issues/7665#issuecomment-3024901004
https://api.github.com/repos/huggingface/datasets/issues/7665
IC_kwDODunzps60TFOM
https://api.github.com/repos/huggingface/datasets/issues/comments/3024901004/reactions
2025-07-01T17:17:31Z
https://api.github.com/repos/huggingface/datasets/issues/comments/3024901004
https://avatars.githubusercontent.com/u/1151198?v=4
https://api.github.com/users/zdzichukowalski/events{/privacy}
https://api.github.com/users/zdzichukowalski/followers
https://api.github.com/users/zdzichukowalski/following{/other_user}
https://api.github.com/users/zdzichukowalski/gists{/gist_id}
https://github.com/zdzichukowalski
zdzichukowalski
MDQ6VXNlcjExNTExOTg=
https://api.github.com/users/zdzichukowalski/orgs
https://api.github.com/users/zdzichukowalski/received_events
https://api.github.com/users/zdzichukowalski/repos
https://api.github.com/users/zdzichukowalski/starred{/owner}{/repo}
https://api.github.com/users/zdzichukowalski/subscriptions
User
https://api.github.com/users/zdzichukowalski
public
### Describe the bug

When loading a `.jsonl` file using `load_dataset("json", data_files="data.jsonl", split="train")`, the function misinterprets the content of a string field  as if it were part of the dataset schema. 

In my case there is a field `body:` with a string value 
```
"### Describe the bug (...) ,action: string, datetime: timestamp[s], author: string, (...) Pandas version: 1.3.4"
```
As a result, I got an exception 
```
"TypeError: Couldn't cast array of type timestamp[s] to null". 
```
Full stack-trace in the attached file below.

I also attach a minimized dataset (data.json, a single entry) that reproduces the error.

**Observations**(on the minimal example): 
- if I remove _all fields before_ `body`, a different error appears,
- if I remove _all fields after_ `body`, yet another error appears,
- if `body` is _the only field_, the error disappears.

So this might be one complex bug or several edge cases interacting. I haven’t dug deeper.

Also changing the file extension to `.json` or `.txt` avoids the problem. This suggests **a possible workaround** for the general case: convert `.jsonl` to `.json`. Though I haven’t verified correctness of that workaround yet.

Anyway my understanding is that `load_dataset` with first argument set to "json" should properly handle `.jsonl` files. Correct me if I'm wrong.

[stack_trace.txt](https://github.com/user-attachments/files/21004153/stack_trace.txt)
[data.json](https://github.com/user-attachments/files/21004164/data.json)

P.S.
I discovered this while going through the HuggingFace tutorial. Specifically [this part](https://huggingface.co/learn/llm-course/chapter5/5?fw=pt).I will try to inform the tutorial team about this issue, as it can be a showstopper for young 🤗 adepts.

### Steps to reproduce the bug

1. Download attached [data.json](https://github.com/user-attachments/files/21004164/data.json) file.
2. Run the following code which should work correctly:
```
from datasets import load_dataset
load_dataset("json", data_files="data.json", split="train")
```
3. Change extension of the `data` file to `.jsonl` and run:
```
from datasets import load_dataset
load_dataset("json", data_files="data.jsonl", split="train")
```

This will trigger an error like the one in the attached [stack_trace.txt](https://github.com/user-attachments/files/21004153/stack_trace.txt).

One can also try removing fields before the `body` field and after it. These actions give different errors.


### Expected behavior

Parsing data in `.jsonl` format should yield the same result as parsing the same data in `.json` format. In any case, the content of a string field should never be interpreted as part of the dataset schema.

### Environment info

datasets version: _3.6.0_
pyarrow version: _20.0.0_
Python version: _3.11.9_
platform version: _macOS-15.5-arm64-arm-64bit_