lihaosky commented on code in PR #26924:
URL: https://github.com/apache/flink/pull/26924#discussion_r2320938943
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/StaticArgument.java:
##########
@@ -144,6 +145,45 @@ public static StaticArgument table(
return new StaticArgument(name, dataType, null, isOptional,
enrichTableTraits(traits));
}
+ /**
+ * Declares a model argument such as {@code f(m => myModel)} or {@code f(m
=> MODEL myModel))}.
+ *
+ * <p>By only providing a conversion class, the argument supports a
"polymorphic" behavior. In
+ * other words: it accepts models with arbitrary schemas or types. For
this case, a class
+ * satisfying the model's conversion requirements must be used.
+ *
+ * @param name name for the assignment operator e.g. {@code f(myArg =>
myModel)}
+ * @param isOptional whether the argument is optional
+ * @param traits set of {@link StaticArgumentTrait} requiring {@link
StaticArgumentTrait#MODEL}
+ */
+ public static StaticArgument model(
+ String name, boolean isOptional, EnumSet<StaticArgumentTrait>
traits) {
+ final EnumSet<StaticArgumentTrait> enrichedTraits =
EnumSet.copyOf(traits);
+ enrichedTraits.add(StaticArgumentTrait.MODEL);
+ return new StaticArgument(name, null, null, isOptional,
enrichedTraits);
+ }
+
+ /**
+ * Declares a model argument such as {@code f(m => myModel)} or {@code f(m
=> MODEL myModel))}.
+ *
+ * <p>By providing a concrete data type, the argument only accepts models
with corresponding
+ * schema or type structure. The data type must be appropriate for the
specific model type.
+ *
+ * @param name name for the assignment operator e.g. {@code f(myArg =>
myModel)}
+ * @param dataType explicit type to which the argument is cast if necessary
Review Comment:
I can remove this method. It's not used and I think we should have both
input and output types. We may extend `StaticArgument` with more than one
datatypes later when needed
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/inference/CallBindingCallContext.java:
##########
@@ -62,6 +65,7 @@ public final class CallBindingCallContext extends
AbstractSqlCallContext {
private final List<DataType> argumentDataTypes;
private final @Nullable DataType outputType;
private final @Nullable List<StaticArgument> staticArguments;
+ private final SqlValidator validator;
Review Comment:
Refactored
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/QueryOperationConverter.java:
##########
@@ -335,6 +335,8 @@ public RelNode visit(FunctionQueryOperation functionTable) {
inputStack.add(relBuilder.build());
return tableArgCall;
}
+ // TODO: Check
ModelReferenceExpression and construct
+ // RexModelArgCall
Review Comment:
Removed
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/expressions/resolver/rules/ResolveCallByArgumentsRule.java:
##########
@@ -651,6 +652,12 @@ public Optional<TableSemantics> getTableSemantics(int pos)
{
return Optional.of(semantics);
}
+ @Override
+ public Optional<ModelSemantics> getModelSemantics(int pos) {
+ // TODO: Add ModelReferenceExpression checks and
TableApiModelSemantics
Review Comment:
Removed
--
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]