-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypedEncoder not working with UDF (or not properly documented) for class having a field typed with a ValueClass #516
Comments
In some case, returning the tupled value for the case class instance + adding ds.makeUDF { .. }.andThen { data =>
data.typed[RowType, CaseClassWithValueClassField](
data.untyped.cast(TypedEncoder[CaseClassWithValueClassField].catalystRepr)
)
} |
Using UDF with injection like that can be tricky. You discovered a case where unfortunately things break at runtime, which is definitely not ideal. I assume you have some data that already encoded in B and you want to initialize them as a TypedDataset[A] using an Injection[A,B]. Is my assumption correct? If that's the case, then simply read your data as a Dataframe with underlying type B (that's going to be String in your example). Then use Example:
|
Hi @imarios , thanks for your feedback. Goal is to be able to use UDF to convert data to instance of case classes where at some point fields are defined as ValueClass. Issue is mixing case class and value class, such as in the previous example. |
The suggestion I have above does what you need without having to use the UDF to convert them. With regards to your comment on ValueClass, are you saying that if Lorem was a case class, then everything would be fine? |
I will check, but I doubt much that we can do without UDF. |
Let me know if case classes solves this (I feel we are going to see the same issue). |
This issue reminds me #161 |
@imarios yes if valueclass is refactored as case class it works, but that's not the wanted modeling. And we cannot do without UDF. |
Even a |
Still not working; Here is a full reproducer: https://github.com/cchantep/frameless-sandbox/blob/master/src/test/scala/EncoderSpec.scala#L33 |
Seem that scalar and struct cases need to be handled differently: https://github.com/cchantep/frameless-sandbox/blob/master/src/test/scala/EncoderSpec.scala#L75 |
Also case of |
Hi,
For now, using frameless 0.10.1, we cannot use value class as a field with
TypedEncoder
andInjection
:This compiles, but throw the following
Exception
at runtime:The text was updated successfully, but these errors were encountered: