Add toDataFrame(KClass) overload to convert type erased lists#825
Add toDataFrame(KClass) overload to convert type erased lists#825
Conversation
|
Generated sources will be updated after merging this PR. |
Jolanrensen
left a comment
There was a problem hiding this comment.
good idea but missing some typing and overloads I think
| properties() | ||
| } | ||
|
|
||
| public fun Iterable<*>.toDataFrame(klass: KClass<*>): DataFrame<*> = |
There was a problem hiding this comment.
I'd add some small KDocs for new public functions :) Also, maybe people want to specify roots/maxdepth as well, would that be possible here?
There was a problem hiding this comment.
Also, since we supply a KClass<T> we can get the type information. If we have an Iterable<Any?>, we know we'll get a DataFrame<T>.
There was a problem hiding this comment.
Finally, would it make sense to offer overloads with body: CreateDataFrameDsl<T>.() -> Unit too?
There was a problem hiding this comment.
Also, since we supply a KClass we can get the type information. If we have an Iterable<Any?>, we know we'll get a DataFrame.
If you have KClass with specific T, i'd say you might as well use list.toDataFrame() without KClass?
Finally, would it make sense to offer overloads with body: CreateDataFrameDsl.() -> Unit too?
Well, this overload is CreateDataFrameDsl<T>.() -> Unit = { properties() } so we'd need to combine them. Also it's supposed to be used when only runtime KClass<*> is available. What useful can be done with CreateDataFrameDsl<Any?>.() -> Unit?
Also, maybe people want to specify roots/maxdepth as well, would that be possible here?
roots - no, because Any?. maxDepth - yes
There was a problem hiding this comment.
If you have KClass with specific T, i'd say you might as well use list.toDataFrame() without KClass?
Hmm, I guess you're right. I first thought it might be possible to use another class as argument of toDataFrame(), then it would make sense to get T... However, that results in java.lang.IllegalArgumentException: object is not an instance of declaring class. It might be worth mentioning in attached KDocs that all elements in the iterable must be exact instances the KClass given.
another case when Iterable has Any? type |
It's not new to have KType / KClass overloads next to inline reified APIs, so i believe this addition would be an easy one.