Question on using a UDT as a struct field from another project #204
-
I'm relatively new to Kotlin and Spark so apologies if this is a newbie question. We have a Scala based Spark job that we'd like to covert to Kotlin for language uniformity. It uses a UDT called Here's a test example:
My question is how can I go about defining this struct schema correctly in Kotlin with this UDT? I've tried the following:
The compilation error is |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Would you also like to convert the |
Beta Was this translation helpful? Give feedback.
So, it all comes down to getting the instance of the Scala singleton from Kotlin, right?
Well, as you've discovered, Scala is a bit less friendly towards other JVM languages compared to Kotlin. Using
MODULE$
is actually the official way to access singleton instances.However, since we're using Kotlin, we can make it a tiny bit simpler, without using reflection, thanks to being able to backtick names: