org.apache.flink.table.api.TableException: A raw type backed by type information has no serializable

2022-03-28 20:45:52 浏览数 (1)

代码语言:javascript复制
DataStream<Order> result = tableEnv.toAppendStream(table, Order.class);

出现这个问题是因为Order类是嵌套内部类,由于不是public类型而导致出现了下面的异常:

代码语言:javascript复制
org.apache.flink.table.api.TableException: A raw type backed by type information has no serializable string representation. It needs to be resolved into a proper raw type.
    at org.apache.flink.table.types.logical.TypeInformationRawType.asSerializableString(TypeInformationRawType.java:101)     at org.apache.flink.table.planner.sinks.TableSinkUtils
anonfunanonfun.apply(TableSinkUtils.scala:95)     at org.apache.flink.table.planner.sinks.TableSinkUtils
anonfun3.apply(TableSinkUtils.scala:95)     at scala.collection.TraversableLike
anonfun$map3.apply(TableSinkUtils.scala:95)     at scala.collection.TraversableLike.apply(TraversableLike.scala:234)     at scala.collection.TraversableLike
anonfun

解决方案是将Order内部类定义为public类型

代码语言:javascript复制
@Data
public static class Order{
    private String name;
    private BigDecimal price;
    private Integer amount;
    private BigDecimal total;
}

0 人点赞