Skip to content

Commit 0fcfcf3

Browse files
authored
Support null in json string cols (#7963)
* support null in json string cols * style
1 parent 201a7d3 commit 0fcfcf3

File tree

1 file changed

+2
-1
lines changed
  • src/datasets/packaged_modules/json

1 file changed

+2
-1
lines changed

src/datasets/packaged_modules/json/json.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ def _cast_table(self, pa_table: pa.Table) -> pa.Table:
105105
.to_json(orient="records", lines=True)
106106
)
107107
string_array = pa.array(
108-
("{" + x.rstrip() for x in ("\n" + jsonl).split("\n{") if x), type=pa.string()
108+
(None if x.strip() == "null" else x.strip() for x in jsonl.split("\n") if x.strip()),
109+
type=pa.string(),
109110
)
110111
pa_table = pa_table.set_column(i, column_name, string_array)
111112
# more expensive cast to support nested structures with keys in a different order

0 commit comments

Comments
 (0)