Skip to content

convertTo() requires values for computed properties #309

@2x2xplz

Description

@2x2xplz

When a class contains computed properties, convertTo() still expects values for those properties to be defined:

@DataSchema
data class Foo (val first : Int, val second : Int) {
    val total : Int get() = first.plus(second)
    val highest : Int get() = listOf<Int>(first, second).max()
}

val df : DataFrame<Foo> = dataFrameOf("first", "second") (
    1, 2,
    25, 75,
    500, 499
).convertTo<Foo>()

java.lang.IllegalArgumentException: The following columns were not found in DataFrame: [highest, total], and their type was not nullable. Use fill to initialize these columns

This affects post-processing after .readCSV(), making it tricky to properly create/convert to a DataFrame reflecting known classes. Instead it's much easier to read the CSV externally, convert rows to collection of classes, then use .toDataFrame().

Trying to use fill results in Unresolved Reference and Type Mismatch (it's certainly possible I have the wrong syntax):

val df : DataFrame<Foo> = dataFrameOf("first", "second") (
    1, 2,
    25, 75,
    500, 499
).convertTo<Foo> {
    fill { total }.with { first.plus(second) }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions