-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FLINK-26782] Remove PlannerExpression and related #23761
Conversation
e61579c
to
3670d5b
Compare
...la/org/apache/flink/table/planner/plan/stream/table/validation/AggregateValidationTest.scala
Outdated
Show resolved
Hide resolved
...ommon/src/main/java/org/apache/flink/table/functions/LegacyUserDefinedFunctionInference.java
Show resolved
Hide resolved
|
||
private static Class<?>[] getParamClassesConsiderVarArgs( | ||
boolean isVarArgs, Class<?>[] matchingSignature, int expectedLength) { | ||
return IntStream.range(0, expectedLength) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit) No need to create a stream to iterate and then make an array.
Looks like https://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html#setAll-T:A-java.util.function.IntFunction- may be an option for doing this in one step / re-using the lambda.
(I don't necessarily think this needs to be addressed.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if that's a better approach.
To be honest I like the single chain approach a bit more. What you're suggesting would look:
final Class<?>[] array = new Class<?>[expectedLength];
Arrays.setAll(array, i -> {
if (i < matchingSignature.length - 1) {
return matchingSignature[i];
} else if (isVarArgs) {
return matchingSignature[matchingSignature.length - 1]
.getComponentType();
} else {
// last argument is not an array type
return matchingSignature[matchingSignature.length - 1];
}
});
return array;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it won't matter (much).
In the old days, Scala could generate tons of intermediate objects to handle things like this. That got me used to looking for when objects were being created just to perform iteration.
This code just reminded me of situations like that!
} | ||
|
||
private static Class<?>[] logicalTypesToExternalClasses(LogicalType[] types) { | ||
return Arrays.stream(types) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the comment about skipping on making a stream and using Arrays.setAll.
|| candidate == TimestampData.class && expected == LocalDateTime.class | ||
|| candidate == Timestamp.class && expected == TimestampData.class | ||
|| candidate == TimestampData.class && expected == Timestamp.class | ||
|| candidate == LocalDateTime.class && expected == TimestampData.class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit) Reorder:
|| candidate == TimestampData.class && expected == LocalDateTime.class
|| candidate == LocalDateTime.class && expected == TimestampData.class
|| candidate == Timestamp.class && expected == TimestampData.class
|| candidate == TimestampData.class && expected == Timestamp.class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather keep the original order from UserDefinedFunctionUtils
final List<Method> found = | ||
filteredMethods.stream() | ||
.sorted(Comparator.comparing(Method::isVarArgs, Boolean::compareTo)) | ||
.filter(cur -> !Modifier.isVolatile(cur.getModifiers())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this check be moved to checkAndExtractMethods
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like no volatile method are ever returned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this check be moved to checkAndExtractMethods?
I'd rather keep the logic as similar to UserDefinedFunctionUtils
as possible. Especially in such a subtle areas as this one. I don't want to analyze all possible corner cases in a class that should be removed any time soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
3670d5b
to
4f2c788
Compare
What is the purpose of the change
Uses the new type inference stack for infering types for the legacy UDF stack.
A no-goal of the PR is to make the logic in
LegacyUserDefinedFunctionInference
more maintainable. It is also a no-goal to move the entire logic 1-1. The legacy is stack is obsolete and this is only a best effort on still supporting it in Table API.Verifying this change
Existing tests pass. I have not added tests for the
LegacyUserDefinedFunctionInference
becauseUserDefinedFunctionUtils
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (yes / no)Documentation