Open
Description
Reading Avro files using Avro-generated classes with org.apache.avro.util.Utf8 fields fails with an exception:
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to org.apache.avro.util.Utf8
at com.example.avro.AvroRecord.put(AvroRecord.java:129)
at org.apache.avro.generic.GenericData.setField(GenericData.java:690)
at org.apache.avro.reflect.ReflectData.setField(ReflectData.java:135)
at org.apache.avro.reflect.ReflectData.setField(ReflectData.java:128)
at org.apache.avro.specific.SpecificDatumReader.readField(SpecificDatumReader.java:119)
at org.apache.avro.reflect.ReflectDatumReader.readField(ReflectDatumReader.java:310)
at org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:222)
at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:175)
at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:153)
at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:145)
at org.apache.beam.sdk.io.AvroSource$AvroBlock.readNextRecord(AvroSource.java:577)
at org.apache.beam.sdk.io.BlockBasedSource$BlockBasedReader.readNextRecord(BlockBasedSource.java:223)
at org.apache.beam.sdk.io.FileBasedSource$FileBasedReader.advanceImpl(FileBasedSource.java:473)
at org.apache.beam.sdk.io.FileBasedSource$FileBasedReader.startImpl(FileBasedSource.java:468)
at
org.apache.beam.sdk.io.OffsetBasedSource$OffsetBasedReader.start(OffsetBasedSource.java:261)
at
org.apache.beam.runners.direct.BoundedReadEvaluatorFactory$BoundedReadEvaluator.processElement(BoundedReadEvaluatorFactory.java:141)
at org.apache.beam.runners.direct.DirectTransformExecutor.processElements(DirectTransformExecutor.java:161)
at org.apache.beam.runners.direct.DirectTransformExecutor.run(DirectTransformExecutor.java:125)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Imported from Jira BEAM-4064. Original Jira may contain additional context.
Reported by: przemekd.