`Map<String, Any?>` to `DataRow` conversion with nested maps
- Dominant language
- Kotlin
- Stars
- 1.1k
- Forks
- 83
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 30
Description
While `map.toDataRow()` is very helpful, there's no easy way to fully unfold nested maps to to datarows, like
```kt
val map = mapOf(
"name" to "a",
"metadata" to
mapOf(
"country" to "Philippines",
"region" to mapOf("name" to "Caraga", "code" to "XIII"),
"population" to mapOf("value" to "12345", "year" to 2020),
"wrongMap" to mapOf(1 to 2, 4 to 4),
),
)
```
Similarly to `unfold` and `toDataFrame()`, we could add a `maxDepth` parameter that would allow us to specify the maximum depth of nesting we scan for and convert.
`convertKeysToString: Boolean` might be another nice addition because there's no way to tell if keys are strings or not until we encounter a `ClassCastException`.
`Iterable>.toDataFrame()` should probably gain the same treatment.
And if we're converting keys to strings anyways, let's make it work for `Map`, why not
Contributor guide
Research direction
Start by reading the implementations and tests for map.toDataRow(), unfold, toDataFrame(), and Iterable>.toDataFrame(). Clarify how maxDepth and convertKeysToString should behave for nested and non-string-keyed maps, then ensure the map and iterable conversions consistently produce the intended DataRows and have coverage for the example cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100