You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support GenerateConstructor annotation on companion object of schema interface to generate default implementation of that interface and append overload for DataFrame:
@DataSchema
interfaceRecord {
val a:Intval b:Int
@GenerateConstructor
companionobject
}
// region Generated Codeoperatorfun Record.Companion.invoke(a:Int, b:Int): Record=object:Record {
overrideval a = a
overrideval b = b
}
fun DataFrame<Record>.append(varargrows:Record) = concat(rows.asIterable().toDataFrame())
// endregion// usage:listOf(Record(1,2), Record(3,4))
.toDataFrame()
.append(Record(5,6))
.add("sum") { a + b }
The text was updated successfully, but these errors were encountered:
nikitinas
changed the title
Generate constructor for DataSchema
Generate constructor for schema interface
May 21, 2022
@DataSchema
interfaceRecord: DataRowSchema {
val a:Intval b:Intcompanionobject
}
// region Generated codeoperatorfun Record.Companion.invoke(a:Int, b:Int): Record=object:Record {
overrideval a = a
overrideval b = b
}
// endregion// usage:
dataFrameOf(Record(1,2), Record(3,4))
.append(Record(5,6))
.add("sum") { a + b }
Can we somehow get rid of DataRowSchema?
In FIR, it's possible to add supertypes to annotated class, so at least it can disappear from user code.
And here is another example to be aware of
// User code:
@DataSchema
interfaceAnotherRecord: DataRowSchema {
val a:Intval b:Intcompanionobject
}
@DataSchema
interfaceRecord: DataRowSchema {
val a:List<AnotherRecord> // same as DataFrame<AnotherRecord>val b:AnotherRecord// same as DataRow<AnotherRecord>companionobject
}
// usage:
dataFrameOf(Record(listOf(AnotherRecord(5,6)), AnotherRecord(5,6)))
Idea was proposed here #113
Better to have it as a part of the compiler plugin.
Plus, using a class instead of an interface already provides the ability to create "rows"
Support
GenerateConstructor
annotation oncompanion object
of schema interface to generate default implementation of that interface andappend
overload forDataFrame
:The text was updated successfully, but these errors were encountered: