flink 1.11 udtf只能通过注解定义输出字段个数和类型吗?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

flink 1.11 udtf只能通过注解定义输出字段个数和类型吗?

李强
各位大佬你们好,我想请教一个问题:
flink 1.11 udtf只能通过注解定义输出字段个数和类型吗,好像不能再通过flink1.10那样重写getResultType方法来定义输出字段类型了,flink1.11里使用getResultType会报错如下:
Caused by: org.apache.flink.table.api.ValidationException: Error in extracting a signature to output mapping.
        at org.apache.flink.table.types.extraction.ExtractionUtils.extractionError(ExtractionUtils.java:313)
        at org.apache.flink.table.types.extraction.FunctionMappingExtractor.extractOutputMapping(FunctionMappingExtractor.java:115)
        at org.apache.flink.table.types.extraction.TypeInferenceExtractor.extractTypeInferenceOrError(TypeInferenceExtractor.java:170)
        at org.apache.flink.table.types.extraction.TypeInferenceExtractor.extractTypeInference(TypeInferenceExtractor.java:158)
        ... 22 more
Caused by: org.apache.flink.table.api.ValidationException: Unable to extract a type inference from method:
public void com.skyon.main.TestFunction.eval(java.lang.String,java.lang.String,long)
        at org.apache.flink.table.types.extraction.ExtractionUtils.extractionError(ExtractionUtils.java:313)
        at org.apache.flink.table.types.extraction.FunctionMappingExtractor.extractResultMappings(FunctionMappingExtractor.java:172)
        at org.apache.flink.table.types.extraction.FunctionMappingExtractor.extractOutputMapping(FunctionMappingExtractor.java:110)
        ... 24 more
Caused by: org.apache.flink.table.api.ValidationException: Could not extract a data type from 'class org.apache.flink.types.Row' in generic class 'org.apache.flink.table.functions.TableFunction' in class com.skyon.main.TestFunction. Please pass the required data type manually or allow RAW types.
        at org.apache.flink.table.types.extraction.ExtractionUtils.extractionError(ExtractionUtils.java:313)
        at org.apache.flink.table.types.extraction.DataTypeExtractor.extractDataTypeOrRawWithTemplate(DataTypeExtractor.java:246)
        at org.apache.flink.table.types.extraction.DataTypeExtractor.extractDataTypeOrRaw(DataTypeExtractor.java:224)
        at org.apache.flink.table.types.extraction.DataTypeExtractor.extractDataTypeWithClassContext(DataTypeExtractor.java:198)
        at org.apache.flink.table.types.extraction.DataTypeExtractor.extractFromGeneric(DataTypeExtractor.java:119)
        at org.apache.flink.table.types.extraction.FunctionMappingExtractor.lambda$createGenericResultExtraction$13(FunctionMappingExtractor.java:443)
        at org.apache.flink.table.types.extraction.FunctionMappingExtractor.putExtractedResultMappings(FunctionMappingExtractor.java:309)
        at org.apache.flink.table.types.extraction.FunctionMappingExtractor.collectMethodMappings(FunctionMappingExtractor.java:252)
        at org.apache.flink.table.types.extraction.FunctionMappingExtractor.extractResultMappings(FunctionMappingExtractor.java:164)
        ... 25 more
Caused by: org.apache.flink.table.api.ValidationException: Cannot extract a data type from a pure 'org.apache.flink.types.Row' class. Please use annotations to define field names and field types.
        at org.apache.flink.table.types.extraction.ExtractionUtils.extractionError(ExtractionUtils.java:313)
        at org.apache.flink.table.types.extraction.ExtractionUtils.extractionError(ExtractionUtils.java:305)
        at org.apache.flink.table.types.extraction.DataTypeExtractor.checkForCommonErrors(DataTypeExtractor.java:343)
        at org.apache.flink.table.types.extraction.DataTypeExtractor.extractDataTypeOrError(DataTypeExtractor.java:277)
        at org.apache.flink.table.types.extraction.DataTypeExtractor.extractDataTypeOrRawWithTemplate(DataTypeExtractor.java:238)
        ... 32 more

 有什么办法动态定义udtf的输出字段个数和类型呢,谢谢了!