0

I have been exploring Beam's Schema related functionality. I tried implementing the @SchemaCreate annotation on a POJO and a JavaBean, but the schema is not being inferred. I keep getting the following exception:

Exception in thread "main" java.lang.RuntimeException: Creator parameter arg0 Doesn't correspond to a schema field
    at org.apache.beam.sdk.schemas.utils.ByteBuddyUtils$InvokeUserCreateInstruction.<init>(ByteBuddyUtils.java:1398)
    at org.apache.beam.sdk.schemas.utils.ByteBuddyUtils$StaticFactoryMethodInstruction.<init>(ByteBuddyUtils.java:1335)
    at org.apache.beam.sdk.schemas.utils.POJOUtils.createStaticCreator(POJOUtils.java:242)

I tried the sample code from Beam documentation of SchemaCreate as below. If I change the code to not use SchemaCreate, it works. Sample code from the documentation of SchemaCreate annotation:

      @DefaultSchema(JavaBeanSchema.class)
  class MyClass {
    public final String user;
    public final int age;

    private MyClass(String user, int age) { this.user = user; this.age = age; }

    @SchemaCreate
    public static MyClass create(String user, int age) {
      return new MyClass(user, age);
    }
 }

I also overrode the equals() and hashCode() methods, but still no luck.

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
saka
  • 1
  • 1
  • Possible duplicate of [this](https://stackoverflow.com/questions/60140366/using-autovalueschema-in-apache-beam-pcollection-gives-runtimeexception-creato). The solution is to pass -parameters option to javac. If you are using Intellij IDEA you an pass this parameter using the config described [here](https://stackoverflow.com/questions/39217830/how-to-use-parameters-javac-option-in-intellij) – Sıddık Açıl Sep 27 '20 at 21:00
  • Also possible using Maven/Gradle, as answered (and commented) here: https://stackoverflow.com/a/60140367/6814598 – DataMacGyver Dec 03 '20 at 11:51
  • Does this answer your question? [Using AutoValueSchema in Apache Beam PCollection gives \`RuntimeException: Creator parameter arg0 Doesn't correspond to a schema field\`](https://stackoverflow.com/questions/60140366/using-autovalueschema-in-apache-beam-pcollection-gives-runtimeexception-creato) – Fokko Driesprong Jan 05 '21 at 10:40

0 Answers0