If I have a PCollection<String> pc and I write

pc.apply(WithKeys.<Void, String>of((Void) null))
  .apply(GroupByKey.<Void, String>create())

I'll get the following failure

java.lang.IllegalStateException: Unable to return a default Coder for
<transform> [PCollection]. Correct one of the following root causes:
  No Coder has been manually specified;  you may do so using .setCoder().
  Inferring a Coder from the CoderRegistry failed: Cannot provide coder for
parameterized type org.apache.beam.sdk.values.KV<K, V>: Unable to provide a
Coder for K.

I can fix this by adding the following after WithKeys.

.setCoder(KvCoder.of(VoidCoder.of(), StringUtf8Coder.of()))


Why can't Beam infer a coder here? String, Void, and KV should all be
registered in the CoderRegistry.


Reuven

Reply via email to