[FLINK-37780][5/N] predict sql function type inference and validation#26583
[FLINK-37780][5/N] predict sql function type inference and validation#26583fsk119 merged 5 commits intoapache:masterfrom
Conversation
a4d988b to
c5b378f
Compare
fsk119
left a comment
There was a problem hiding this comment.
Thanks for your contribution. I left some comments
| // 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.
nit: Do we need to validate this again? SqlMLTableFunction#validateCall has already validated it.
There was a problem hiding this comment.
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.
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
| @@ -112,5 +140,92 @@ public String getAllowedSignatures(SqlOperator op, String opName) { | |||
| return opName | |||
| + "(TABLE table_name, MODEL model_name, DESCRIPTOR(input_columns), [MAP[]]"; | |||
| return typeFactory | ||
| .builder() | ||
| .kind(inputRowType.getStructKind()) | ||
| .addAll(inputRowType.getFieldList()) |
There was a problem hiding this comment.
Take a look at SystemOutputStrategy#inferType.
There was a problem hiding this comment.
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.
Yes. Otherwise, you will get an error here.
There was a problem hiding this comment.
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
What is the purpose of the change
Validate predict function arguments
Brief change log
SqlModelCallVerifying this change
Unit test
Does this pull request potentially affect one of the following parts:
@Public(Evolving): (no)Documentation