-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[FLINK-37780][5/N] predict sql function type inference and validation #26583
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
Conversation
a4d988b
to
c5b378f
Compare
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.
Thanks for your contribution. I left some comments
...-planner/src/main/java/org/apache/flink/table/planner/functions/utils/SqlValidatorUtils.java
Outdated
Show resolved
Hide resolved
// TODO: FLINK-37780 Check operand types after integrated with SqlExplicitModelCall in | ||
// validator | ||
return false; | ||
if (!SqlValidatorUtils.checkTableAndDescriptorOperands(callBinding, 2, 1)) { |
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: Do we need to validate this again? SqlMLTableFunction#validateCall has already validated it.
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.
validateCall
doesn't check the position and count of descriptor also doesn't check first param needs to be table. validateCall
can be used by both ml_predict
and ml_evaluate
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.
OK. I dropped the validation for descriptor in validateCall
since it make the column name complex and failed later stage in rel converter: https://github.com/apache/flink/blob/master/flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java#L2250-L2254
...src/main/java/org/apache/flink/table/planner/functions/sql/ml/SqlMLPredictTableFunction.java
Show resolved
Hide resolved
@@ -112,5 +140,92 @@ public String getAllowedSignatures(SqlOperator op, String opName) { | |||
return opName | |||
+ "(TABLE table_name, MODEL model_name, DESCRIPTOR(input_columns), [MAP[]]"; |
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.
Do you miss the )
here?
...src/main/java/org/apache/flink/table/planner/functions/sql/ml/SqlMLPredictTableFunction.java
Show resolved
Hide resolved
return typeFactory | ||
.builder() | ||
.kind(inputRowType.getStructKind()) | ||
.addAll(inputRowType.getFieldList()) |
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.
Take a look at SystemOutputStrategy#inferType.
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.
Do you mean we need to make field names unique? I'm following SqlWindowTableFunction
which doesn't check if input table column has window_start
etc. I'm on the fence here
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.
Yes. Otherwise, you will get an error here.
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.
Yes. I have a test case for this: https://github.com/apache/flink/pull/26583/files#diff-f6cf1751f150530409425ff9ada80d1cf32c44d1558b20fa6cf64664525ec998R138-R154. OK. I will allow conflict names
1dcf660
to
6031544
Compare
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.
LGTM
What is the purpose of the change
Validate predict function arguments
Brief change log
SqlModelCall
Verifying this change
Unit test
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (no)Documentation