lihaosky commented on code in PR #26924:
URL: https://github.com/apache/flink/pull/26924#discussion_r2322811232
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/SpecificInputTypeStrategies.java:
##########
@@ -181,4 +226,139 @@ public static ArgumentTypeStrategy
percentageArray(boolean expectedNullability)
private SpecificInputTypeStrategies() {
// no instantiation
}
+
+ private static Optional<List<DataType>> inferMLPredictInputTypes(
+ CallContext callContext, boolean throwOnFailure) {
+ // Check that first argument is a table
+ TableSemantics tableSemantics =
callContext.getTableSemantics(0).orElse(null);
+ if (tableSemantics == null) {
+ if (throwOnFailure) {
+ throw new ValidationException(
+ "First argument must be a table for ML_PREDICT
function.");
+ } else {
+ return Optional.empty();
+ }
+ }
+
+ // Check that second argument is a model
+ ModelSemantics modelSemantics =
callContext.getModelSemantics(1).orElse(null);
+ if (modelSemantics == null) {
+ if (throwOnFailure) {
+ throw new ValidationException(
+ "Second argument must be a model for ML_PREDICT
function.");
+ } else {
+ return Optional.empty();
+ }
+ }
+
+ // Check that third argument is a descriptor with column names
+ Optional<ColumnList> descriptorColumns =
callContext.getArgumentValue(2, ColumnList.class);
+ if (descriptorColumns.isEmpty()) {
+ if (throwOnFailure) {
+ throw new ValidationException(
+ "Third argument must be a descriptor with simple
column names for ML_PREDICT function.");
+ } else {
+ return Optional.empty();
+ }
Review Comment:
@twalthr , I added these checks back since I have tests in
`MLPredictInputTypeStrategyTest` testing invalid argument as well. Also
`tableSemantics` etc are needed below. Maybe doesn't hurt to do extra check and
give meaningful error message.
--
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]