hanyuzheng7 commented on code in PR #22951:
URL: https://github.com/apache/flink/pull/22951#discussion_r1486472909
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/BuiltInFunctionDefinitions.java:
##########
@@ -231,6 +231,22 @@ ANY, and(logical(LogicalTypeRoot.BOOLEAN), LITERAL)
"org.apache.flink.table.runtime.functions.scalar.ArrayContainsFunction")
.build();
+ public static final BuiltInFunctionDefinition ARRAY_SORT =
+ BuiltInFunctionDefinition.newBuilder()
+ .name("ARRAY_SORT")
+ .kind(SCALAR)
+ .inputTypeStrategy(
+ or(
+ sequence(ARRAY_COMPARABLE),
+ sequence(
+ ARRAY_COMPARABLE,
+ InputTypeStrategies.explicit(
Review Comment:
If we not use InputTypeStrategies.explicit here, it will conflict with
`import static
org.apache.flink.table.types.inference.TypeStrategies.explicit;`
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/SpecificInputTypeStrategies.java:
##########
@@ -89,6 +90,10 @@ public static InputTypeStrategy windowTimeIndicator() {
public static final ArgumentTypeStrategy ARRAY_ELEMENT_ARG =
new ArrayElementArgumentTypeStrategy();
+ /** Argument type representing the array is comparable. */
+ public static final ArgumentTypeStrategy ARRAY_COMPARABLE =
Review Comment:
ok
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementArgumentTypeStrategy.java:
##########
@@ -34,40 +32,33 @@
import
org.apache.flink.table.types.logical.StructuredType.StructuredComparison;
import org.apache.flink.util.Preconditions;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
/**
- * An {@link InputTypeStrategy} that checks if the input argument is an ARRAY
type and check whether
- * its' elements are comparable.
+ * An {@link ArgumentTypeStrategy} that checks if the input argument is an
ARRAY type and check
+ * whether its' elements are comparable.
*
* <p>It requires one argument.
*
* <p>For the rules which types are comparable with which types see {@link
* #areComparable(LogicalType, LogicalType)}.
*/
@Internal
-public final class ArrayComparableElementTypeStrategy implements
InputTypeStrategy {
+public final class ArrayComparableElementArgumentTypeStrategy implements
ArgumentTypeStrategy {
+
private final StructuredComparison requiredComparison;
- private final ConstantArgumentCount argumentCount;
- public ArrayComparableElementTypeStrategy(StructuredComparison
requiredComparison) {
+ public ArrayComparableElementArgumentTypeStrategy(StructuredComparison
requiredComparison) {
Preconditions.checkArgument(requiredComparison !=
StructuredComparison.NONE);
this.requiredComparison = requiredComparison;
- this.argumentCount = ConstantArgumentCount.of(1);
- }
-
- @Override
- public ArgumentCount getArgumentCount() {
- return argumentCount;
}
@Override
- public Optional<List<DataType>> inferInputTypes(
- CallContext callContext, boolean throwOnFailure) {
+ public Optional<DataType> inferArgumentType(
+ CallContext callContext, int argumentPos, boolean throwOnFailure) {
final List<DataType> argumentDataTypes =
callContext.getArgumentDataTypes();
- final DataType argumentType = argumentDataTypes.get(0);
+ final DataType argumentType = argumentDataTypes.get(argumentPos);
if (!argumentType.getLogicalType().is(LogicalTypeRoot.ARRAY)) {
return callContext.fail(throwOnFailure, "All arguments requires to
be an ARRAY type");
Review Comment:
ok
--
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]