- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.8k
[FLINK-38104][table] add table api support for model ml_predict #27108
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
base: master
Are you sure you want to change the base?
Conversation
| * | ||
| * @return the context resolved model metadata. | ||
| */ | ||
| ContextResolvedModel getModel(); | 
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.
@twalthr , this forces ContextResolvedModel to be PublicEvolving. I guess one way to avoid it is to remove this method from Model and just add it in ModelImpl
074a935    to
    982f128      
    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.
| * runtime configuration options such as max-concurrent-operations, timeout, and execution mode | ||
| * settings. | ||
| * | ||
| * <p>Common runtime options include: | 
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.
It's not easy for the community to maintain the javadoc about these options. How about we just link the MLPredictRuntimeConfigOptions.
| // lit() is not serializable to sql. | ||
| if (options.isEmpty()) { | ||
| return tableEnvironment.fromCall( | ||
| "ML_PREDICT", | 
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.
use org.apache.flink.table.functions.BuiltInFunctionDefinitions#ML_PREDICT.getName() instead?
|  | ||
| @Override | ||
| public Table predict(Table table, ColumnList inputColumns, Map<String, String> options) { | ||
| // Use Expressions.map() instead of Expression.lit() to create a MAP literal since | 
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.
typo: Expressions.lit() ?
| table.asArgument("INPUT"), | ||
| this.asArgument("MODEL"), | ||
| Expressions.descriptor(inputColumns).asArgument("ARGS"), | ||
| Expressions.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.
use Expressions.mapFromArrays instead.
| .map(this::createModel) | ||
| .orElseThrow( | ||
| () -> | ||
| new ValidationException( | 
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.
throw ModelNotExistException?
|  | ||
| private final String name; | ||
| private final ContextResolvedModel model; | ||
| private final TableEnvironment env; | 
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.
Why do we need TableEnv here?
|  | ||
| @Override | ||
| public <R> R accept(ExpressionVisitor<R> visitor) { | ||
| return visitor.visit(this); | 
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 we need to add a default method for ResolvedExpressionDefaultVisitor?
|  | ||
| public abstract R visit(TableReferenceExpression tableReference); | ||
|  | ||
| public abstract R visit(ModelReferenceExpression modelReferenceExpression); | 
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.
Add else if  branch in line 30?
| new int[0]); | ||
| inputStack.add(relBuilder.build()); | ||
| return tableArgCall; | ||
| } else if (resolvedArg | 
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.
I don't think it's a good idea to use instance of here. It's better we reuse ExpressionConverter to convert these expression. How about let ExpressionConverterextends ResolvedExpressionVisitor<RexNode>?
| ExecutionConfigOptions.AsyncOutputMode.ALLOW_UNORDERED) | ||
| .runTableApi( | ||
| env -> | ||
| env.fromModel("chatgpt") | 
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.
No tests for anoymous model?
What is the purpose of the change
Add table api support for Model and ml_predict function in https://cwiki.apache.org/confluence/display/FLINK/FLIP-526%3A+Model+ML_PREDICT%2C+ML_EVALUATE+Table+API
Brief change log
Modelinterface andModelImplimplementation for model and ml_predictfromModelPathandfromto constructModelfromTableEnvironmentModelReferenceExpressionand handle it inQueryOperationConverterContextResolvedModelVerifying this change
Unit and Integration test
Does this pull request potentially affect one of the following parts:
@Public(Evolving): (yes)Documentation