Kotlin / Kotlin/dataframe

[Bug] `DataFrame.toJson()` value column detection drops all other columns

Open
#2,045 0 comments 0 reactions 1 assignee Claimed by @AndreiKingsley View on GitHub
bug
Dominant language
Kotlin
Stars
1.1k
Forks
83
Avg merge
4d 12h
Merged PRs (30d)
30

Description

Based on https://github.com/Kotlin/dataframe/pull/2037#discussion_r3853043565

Turning a DataFrame into JSON ignores all columns that are not value- or array columns if they exist:

If we read
```kt
DataFrame.readJsonStr( """[1,{"label":"record"},null]""")
```
we get:
``` label value
String? Int?
---- ----
0 null 1
1 record null
2 null null
```

and then `.toJson()`:
```json
[1,null,null]
```

`label: "record"` has been lost.

### Expected behavior
```kt
DataFrame.readJsonStr( """[1,{"label":"record"},null]""").toJson()
```
should return values from (correctly recognized) array and value columns back into the JSON array, like:
```json
[1,{"label":"record"},null]
```

(Related: https://github.com/Kotlin/dataframe/issues/2046 our `array` column detection is completely broken because it checks for `null` values, however, array columns are created with `emptyList()` instead.)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.