org.apache.flink.table.api.ValidationException: SQL validation failed. An error occurred in the type inference logic of function ‘default_catalog.default_database.CollectSetSort’.
org.apache.flink.table.api.ValidationException: An error occurred in the type inference logic of function ‘default_catalog.default_database.CollectSetSort’.
org.apache.flink.table.api.ValidationException: Could not extract a valid type inference for function class ‘com.xiaomi.cloud.streaming.computing.udagg.CollectSetSort’. Please check for implementation mistakes and/or provide a corresponding hint.
org.apache.flink.table.api.ValidationException: Error in extracting a signature to accumulator mapping.
org.apache.flink.table.api.ValidationException: Unable to extract a type inference from method:
public void com.xiaomi.cloud.streaming.computing.udagg.CollectSetSort.accumulate(java.util.ArrayList,java.lang.Integer)
org.apache.flink.table.api.ValidationException: Could not extract a data type from ‘java.util.ArrayList<java.lang.Integer>’ in generic class ‘org.apache.flink.table.functions.AggregateFunction’ in class com.xiaomi.cloud.streaming.computing.udagg.CollectSetSort. Please pass the required data type manually or allow RAW types.
org.apache.flink.table.api.ValidationException: Could not extract a data type from ‘java.util.ArrayList<java.lang.Integer>’. Interpreting it as a structured type was also not successful.
org.apache.flink.table.api.ValidationException: Field ‘size’ of class ‘java.util.ArrayList’ is mutable but is neither publicly accessible nor does it have a corresponding setter method.
这个报错org.apache.flink.table.api.ValidationException: Could not extract a data type from ‘java.util.ArrayList<java.lang.Integer>’ in generic class ‘org.apache.flink.table.functions.AggregateFunction’ in class com.xiaomi.cloud.streaming.computing.udagg.CollectSetSort. Please pass the required data type manually or allow RAW types.
是因为我代码中AggregateFunction 定义的参数是 extends AggregateFunction<String, ArrayList>
java中的数据类型分两种 一个是基本类 一个是封装类。例如 数据类型int是Java中的基本数据类型,而Integer是int的封装类。
这里我用了封装类,导致无法解析数据类型,改用了 java.lang.long 直接声明引用就可以了。
另一个报错
org.apache.flink.table.api.ValidationException: Field ‘size’ of class ‘java.util.ArrayList’ is mutable but is neither publicly accessible nor does it have a corresponding setter method.
这是因为 ArrayList是封装类型,在udf中 访问其中的私有方法访问不到,所以应该用 List ,在创建的时候
返回List接口 就可以了