Kotlin / Kotlin/dataframe

Consider relaxing type requirement in df.cast(verify = true) operation to allow subtype relation

Open
#1,549 0 comments 1 reaction 1 assignee Claimed by @koperagen View on GitHub
enhancement
Dominant language
Kotlin
Stars
1.1k
Forks
83
Avg merge
4d 12h
Merged PRs (30d)
30

Description

cast(verify = true) will fail if some column has more specific runtime type than expected, for example Int and not Number?, or even `Int?`:

```kt
@DataSchema
data class Input(val b: Number?)

fun process(df: DataFrame) {
df.forEach { println("row ${index()}: $b") }
}

fun main() {
dataFrameOf("b" to columnOf(123)).cast(verify = true)
}
```

My intention with this operation to process different dataframes that can be processed, fail fast anything that would otherwise fail with classcast exception. But here it's not the case. This code will work without verify = true or if i switch to convertTo.
I think it somewhat hurts writing reliable programs. It's not clear that `cast` might fail and what's the alternative. convertTo is more reliable, but it has its own caveat of filling missed columns with nulls

```kt
dataFrameOf("b" to columnOf(123)).cast(verify = false)
dataFrameOf("b" to columnOf(123)).convertTo()
```

We need to improve cast reliability to serve as accurate fail fast mechanism

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.