Add a possibility to instantiate schema type instance
- Dominant language
- Kotlin
- Stars
- 1.1k
- Forks
- 83
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 30
Description
Inspired by #309 (https://github.com/Kotlin/dataframe/issues/309#issuecomment-1482237061).
Would be nice to get an instance of actual class.
Something like
```kt
fun DataRow.toInstance(): T
```
```kt
data class Point(val x: Double, y: Double) {
fun countF(): Double = x * x + y * y
}
df.cast().add("f") {
toInstance().countF()
}
```
In fact we have it now for the whole `DataFrame` — `toList()` and `toListOf()`, and now you can do it like.
```
dataRow.toDataFrame().toList().single()
```
Contributor guide
Research direction
Start by reading the existing DataFrame toList() and toListOf() conversion paths, then compare them with DataRow and the toDataFrame().toList().single() workaround shown in the issue. The feature is complete when a typed row supports the proposed toInstance() usage and the Point example can call countF() successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- data
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100