核心代码
public class TrackLog {
private Integer entityId;
// flink的时间类型,必须使用LocalDateTime
private LocalDateTime statDateTime;
public Integer getEntityId() {
return entityId;
}
public void setEntityId(Integer entityId) {
this.entityId = entityId;
}
public LocalDateTime getStatDateTime() {
return statDateTime;
}
public void setStatDateTime(LocalDateTime statDateTime) {
this.statDateTime = statDateTime;
}
}
SideOutputDataStream<TrackLog> patrolStream = traceStream.getSideOutput(outputLogTag);
Table table = tableEnv.fromDataStream(patrolStream);
table.printSchema();
会输出:
(
`entityId` INT,
`statDateTime` RAW('java.time.LocalDateTime', '...')
)
问题一: 往POJO类(TrackLog)中private 属性isDup,未定义getter方法
public class TrackLog {
private Integer entityId;
// flink的时间类型,必须使用LocalDateTime
private LocalDateTime statDateTime;
private boolean isDup = false;
public Integer getEntityId() {
return entityId;
}
public void setEntityId(Integer entityId) {
this.entityId = entityId;
}
public LocalDateTime getStatDateTime() {
return statDateTime;
}
public void setStatDateTime(LocalDateTime statDateTime) {
this.statDateTime = statDateTime;
}
}
再运行:
(
`f0` RAW('com.tide.entity.TrackLog', '...')
)
schema中,只有f0一个field,类型是TrackLog,也就是说,在把POJO类的fields映射到表时,出现了问题。
很奇怪,debug了好久才发现问题所在。