Kotlin / dataframe

Structured data processing in Kotlin
https://kotlin.github.io/dataframe/overview.html
Apache License 2.0
772 stars 48 forks source link

`withValue(value)` consistency #253

Closed Jolanrensen closed 1 year ago

Jolanrensen commented 1 year ago

Some functions in the API have the option withValue such as update { something }.withValue(value) while other functions, such as convert {} say they have it in the docs, yet don't.

We need to either add withValue everywhere a with occurs or just remove withValue from the entire API since with { value } does the same thing.

Jolanrensen commented 1 year ago

Let's remove withValue from update (neat deprecation with ReplaceWith ofc) and remove it everywhere in the docs

koperagen commented 1 year ago

Hm, i have concerns about deprecation of this method because we can break examples in notebooks (especially in datalore) and there is at least one screenshot of some code in docs

Jolanrensen commented 1 year ago

Well, we can change those right? Good to know but it doesn't seem like a showstopper :)

Jolanrensen commented 1 year ago

Aah wait, Update.withValue does have some use, namely keeping the type and nullability the same :) with {} allows the type to change.

Jolanrensen commented 1 year ago

Btw Update.asNullable is fairly useless. All it does is cast Update<T, C> -> Update<T, C?>. This is then only useful for Update.asNullable().withValue(null) because withValue expects an exact type match. But we can just as easily allow withValue to change nullability or just make users use with { null } since that allows all type/nullability changes.

koperagen commented 1 year ago

Well, we can change those right? Good to know but it doesn't seem like a showstopper :)

Sure, just something to keep in mind

Regarding nullability, if with indeed allows nullability change, then asNullable looks like a leftover. Maybe it wasn't always possible. I vaguely remember there were design discussions about it, but i don't remember the final decision. Also, apart from withValue we also have withZero, withNull.

Jolanrensen commented 1 year ago

Yes, I'm indifferent to keep or remove withZero and withNull. Could be a handy addition since it's less typing than with { 0.0 } especially if autocompleted. I see more use in those than withValue(value)

nikitinas commented 1 year ago

Originally withValue was added to support possible performance optimizations, for example when user fills a long column with a single constant value (#291 )

zaleslaw commented 1 year ago

@Jolanrensen please revisit this