snuyanzin commented on code in PR #25805:
URL: https://github.com/apache/flink/pull/25805#discussion_r1890264653
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/extraction/FunctionMappingExtractor.java:
##########
@@ -185,101 +154,169 @@ static ResultExtraction
createGenericResultExtractionFromMethod(
method,
paramPos,
genericPos);
- return FunctionResultTemplate.of(dataType);
+ return FunctionResultTemplate.ofOutput(dataType);
};
}
- /** Uses hints to extract functional template. */
- private static Optional<FunctionResultTemplate> extractHints(
- BaseMappingExtractor extractor, Method method) {
- final Set<DataTypeHint> dataTypeHints = new HashSet<>();
- dataTypeHints.addAll(collectAnnotationsOfMethod(DataTypeHint.class,
method));
- dataTypeHints.addAll(
- collectAnnotationsOfClass(DataTypeHint.class,
extractor.getFunctionClass()));
- if (dataTypeHints.size() > 1) {
- throw extractionError(
- "More than one data type hint found for output of
function. "
- + "Please use a function hint instead.");
- }
- if (dataTypeHints.size() == 1) {
- return Optional.ofNullable(
- FunctionTemplate.createResultTemplate(
- extractor.typeFactory,
dataTypeHints.iterator().next()));
- }
- // otherwise continue with regular extraction
- return Optional.empty();
- }
+ //
--------------------------------------------------------------------------------------------
+ // Verification strategies
+ //
--------------------------------------------------------------------------------------------
- /** Verification that checks a method by parameters and return type. */
+ /** Verification that checks a method by parameters (arguments only) and
return type. */
static MethodVerification createParameterAndReturnTypeVerification() {
- return (method, signature, result) -> {
- final Class<?>[] parameters = signature.toArray(new Class[0]);
+ return (method, state, arguments, result) -> {
+ checkNoState(state);
+ checkScalarArgumentsOnly(arguments);
+ final Class<?>[] parameters = assembleParameters(null, arguments);
+ assert result != null;
+ final Class<?> resultClass = result.toClass();
final Class<?> returnType = method.getReturnType();
final boolean isValid =
- isInvokable(method, parameters) && isAssignable(result,
returnType, true);
+ isInvokable(true, method, parameters)
+ && isAssignable(resultClass, returnType, true,
false);
Review Comment:
Should there be something like an enum with different kinds of autoboxing
rather than a list of boolean flags?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]