A1 报错
A2 原因
lambda表达式编写方式不自动识别返回类型,需要手动跟上returns指定类型。
源码:
代码语言:javascript复制/**
* Adds a type information hint about the return type of this operator. This method
* can be used in cases where Flink cannot determine automatically what the produced
* type of a function is. That can be the case if the function uses generic type variables
* in the return type that cannot be inferred from the input type.
*
* In most cases, the methods {@link #returns(Class)} and {@link #returns(TypeHint)}
* are preferable.
*
* @param typeInfo type information as a return type hint
* @return This operator with a given return type hint.
*/
public SingleOutputStreamOperator<T> returns(TypeInformation<T> typeInfo) {
requireNonNull(typeInfo, "TypeInformation must not be null");
transformation.setOutputType(typeInfo);
return this;
}
A3 解决
对象后调用returns方法