Skip to content

Generate constructor for schema interface #113

@nikitinas

Description

@nikitinas

Support GenerateConstructor annotation on companion object of schema interface to generate default implementation of that interface and append overload for DataFrame:

@DataSchema
interface Record {
    val a: Int
    val b: Int

    @GenerateConstructor
    companion object
}

// region Generated Code

operator fun Record.Companion.invoke(a: Int, b: Int): Record =
    object: Record {
        override val a = a
        override val b = b
    }

fun DataFrame<Record>.append(vararg rows: Record) = concat(rows.asIterable().toDataFrame())

// endregion

// usage:

listOf(Record(1,2), Record(3,4))
  .toDataFrame()
  .append(Record(5,6))
  .add("sum") { a + b }

Metadata

Metadata

Assignees

Labels

researchThis requires a deeper dive to gather a better understanding

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions