for context, I’m trying to write a Apache Beam job that writes to Kafka using Kotlin. The KafkaIO package has some example code I’m trying to convert to Kotlin (under Reading Kafka Topics.
This works fine, until the last line, in Java being:
writing this in Kotlin as
gives me a type mismatch error.
Error:(24, 13) Kotlin: Type mismatch: inferred type is Values<String!>! but PTransform<in PCollection<KafkaRecord<Long!, String!>!>!, PCollection<String!>!>! was expected
But Values<String!>! should be a subclass of PTransform. Here’s its Javadoc: https://beam.apache.org/releases/javadoc/2.5.0/org/apache/beam/sdk/transforms/Values.html
I don’t understand why this works in Java, but not in Kotlin. What with it being a million generics deep type, there’s probably an issue there, but type stuff has always been my weak point. Any help would be appreciated.