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.