Skip to content

Conversation

Jolanrensen
Copy link
Collaborator

fix for #136

The problem with the example was the following:

@DataSchema
interface SchemaA { val i: Int? }

@DataSchema
interface SchemaB { val i: Int }

val df = dataFrameOf("i")(1, null)

df.fillNulls(SchemaA::i).with { it: Int? -> 42 }

// breaks because `null != Int`
df.fillNulls(SchemaB::i).with { it: Int -> 42 } 

This makes sense from a programming standpoint: Essentially a column with null values is matched to a schema with a non-null column. However, since the intention is to fill in those nulls, it might be okay for us to assume that this is fine. I think it's reasonable to say that for any fillNulls- and fillNA call, the values should be considered nullable in the with statement. This PR fixes that.

So now:

df.fillNulls(SchemaA::i).with { it: Int? -> 42 }

df.fillNulls(SchemaB::i).with { it: Int? -> 42 } 

@Jolanrensen Jolanrensen added bug Something isn't working enhancement New feature or request labels Dec 9, 2022
@Jolanrensen Jolanrensen added this to the 0.9.0 milestone Dec 9, 2022
@Jolanrensen Jolanrensen requested a review from koperagen December 9, 2022 13:21
@Jolanrensen Jolanrensen merged commit 1c95cf4 into master Dec 13, 2022
@Jolanrensen Jolanrensen deleted the npe-update-not-null-prop branch December 13, 2022 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants