Kotlin / Kotlin/dataframe

Support sealed interface data schemas

Open
#912 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Kotlin
Stars
1.1k
Forks
83
Avg merge
4d 12h
Merged PRs (30d)
30

Description

From Slack discussion, there can be a situation when an input file can have one of few specific data schemas. It would be nice to be able to apply transformations to different schemas, basically like dynamic dispatch in OOP. With some code generation, it's possible:
```
@SealedDataSchema
sealed interface Test {
val a: Int

companion object
}

@DataSchema
interface Test2 : Test {
val b: String
}

@DataSchema
interface Test3 : Test {
val c: String
}
```

generated code:
```
sealed class Wrapper {
abstract val df: DataFrame
}

class Wrapper2 : Wrapper {
override val df: DataFrame
}

class Wrapper3 : Wrapper {
override val df: DataFrame
}

fun Test.Companion.of(df: DataFrame<*>): Wrapper? {
TODO("need to figure out this part, need to pick most suitable schema for df")
}

// might be useful to have same for DataRow
fun Test.Companion.of(df: DataRow<*>): Wrapper? {
TODO("need to figure out this part, need to pick most suitable schema for df")
}
```

use:
```
fun transform(df: DataFrame<*>) {
val typed = Test.of(df)
when (typed) {
is Wrapper -> typed.df.a
is Wrapper2 -> typed.df.b
is Wrapper3 -> typed.df.c
null -> ...
}
}
```

Contributor guide

Open the contributing guide

Research direction

No repository files or tests are named. Start by reviewing the Slack discussion referenced in the issue and the sealed-schema, DataFrame, and DataRow examples to define schema selection and wrapper behavior; done would mean a decided design for supporting these transformations.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.