-
Notifications
You must be signed in to change notification settings - Fork 76
Closed
Description
type: KType in DataColumnImpl mismatches actual values in some cases. This can result in runtime exceptions and makes life difficult attempting to fix #30 or #704 where we assume the type always correctly represents the data.
This issue relates to #701 as well.
To discover these bugs, we can introduce a (debug-only!!) check in DataColumnImpl, like:
private infix fun <T> T?.matches(type: KType) =
when {
this == null -> type.isMarkedNullable
this.isPrimitiveArray -> type.isPrimitiveArray &&
this!!::class.qualifiedName == type.classifier?.let { (it as KClass<*>).qualifiedName }
this.isArray -> type.isArray // cannot check the precise type of array
else -> this!!::class.isSubclassOf(type.classifier as KClass<*>)
}
init {
if (DEBUG) {
require(values.all { it matches type }) {
val types = values.map { if (it == null) "Nothing?" else it!!::class.simpleName }.distinct()
"Values of column '$name' have types '$types' which are not compatible given with column type '$type'"
}
}
}At the moment of testing, I can find 8+ breaking tests in :core:
org.jetbrains.kotlinx.dataframe.io.PlaylistJsonTest#aggregate by column- data has types
[DataFrameImpl],kTypeis:org.jetbrains.kotlinx.dataframe.aggregation.AggregateGroupedDsl<org.jetbrains.kotlinx.dataframe.io.PlaylistJsonTest.DataFrameType1> - This exception is probably fine to ignore, as
AggregateGroupedDslis aDataFrame
- data has types
org.jetbrains.kotlinx.dataframe.samples.api.Analyze#pivotDefault_accessors/#pivotDefault_strings/#pivotDefault_properties- data has types
[Boolean, Int],kTypeis:kotlin.Boolean - Not really sure what's going on here, something with
concatImplI think
- data has types
org.jetbrains.kotlinx.dataframe.samples.api.Modify#customConverters- data has types
[Nothing?],kTypeiskotlin.Int - Seems to originate from
convertToImpl$convertToSchema
- data has types
org.jetbrains.kotlinx.dataframe.samples.api.Modify#implode- data has types
[DataFrameImpl, Nothing?],kTypeis:org.jetbrains.kotlinx.dataframe.DataFrame<*>, not nullable - Seems to originate from
implodeImplwhere anullis put in aFrameColumn
- data has types
org.jetbrains.kotlinx.dataframe.testSets.person.DataFrameTests#convertTo- data has type:
[Nothing?],kTypeis:kotlin.Int - From
convertToImpl$convertToSchematoo
- data has type:
org.jetbrains.kotlinx.dataframe.testSets.person.DataFrameTreeTests#merge rows into table- data has types
[DataFrameImpl, Nothing?],kTypeis:org.jetbrains.kotlinx.dataframe.DataFrame<*>, not nullable - Seems to originate from
implodeImpltoo where anullis put in aFrameColumn
- data has types
Edit: running it afresh (clean pull of master with check) I get 15 failing tests.
There is also an exception in :dataframe-jdbc: #701
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working