Hi, Tejas

These code is works in my idea environment.
Could you provide more error info or log?


Best,
Weihua

> 2022年5月10日 下午1:22,Tejas B <tejasub1...@gmail.com> 写道:
> 
> Hi,
> I am trying to get flink schema evolution to work for me using POJO 
> serializer. But I found out that if an enum is present in the POJO then the 
> POJO serializer is not used. Example of my POJO is as follows :
> public class Rule {
> String id;
> int val;
> RuleType ruleType;
> //Newly added field
> //int val2 = 0;
> 
> public Rule() {}
> 
> public Rule(String id, int val, RuleType ruleType) {
>     this.id = id;
>     this.val = val;
>     this.ruleType = ruleType;
>     //this.val2 = val2;
> }
> 
> public String getId() {
>     return id;
> }
> 
> public void setId(String id) {
>     this.id = id;
> }
> 
> public int getVal() {
>     return val;
> }
> 
> public void setVal(int val) {
>     this.val = val;
> }
> 
> public RuleType getRuleType() {
>     return ruleType;
> }
> 
> public void setRuleType(RuleType ruleType) {
>     this.ruleType = ruleType;
> }
> 
> //public int getVal2() {
> //    return val2;
> //}
> 
> //public void setVal2(int val2) {
> //    this.val2 = val2;
> //}
> 
> @Override
> public boolean equals(Object o) {
>     if (this == o) return true;
>     if (o == null || getClass() != o.getClass()) return false;
>     Rule rule = (Rule) o;
>     return val == rule.val && id.equals(rule.id <http://rule.id/>) && 
> ruleType == rule.ruleType;
> }
> 
> @Override
> public int hashCode() {
>     return Objects.hash(id, val, ruleType);
> }
> 
> @Override
> public String toString() {
>     return "Rule{" +
>             "name='" + id + '\'' +
>             ", val=" + val +
>             ", ruleType=" + ruleType +
>             '}';
> }
> }
> 
> RuleType is an enum class as follows :
> 
> public enum RuleType {
>     X,
>     Y,
>     Z
> }
> Now for the Rule class the schema evolution (Adding a new field called val2), 
> works only if I write a custom typeFactory for this class.
> 
> Is there a way that I can write typeFactory for the enum class ? Why does the 
> flink not recognize enum in a POJO class ?
> 

Reply via email to