haruki-830 opened a new pull request, #4525: URL: https://github.com/apache/flink-cdc/pull/4525
## What is the purpose of this pull request? This PR fixes [FLINK-40572](https://issues.apache.org/jira/browse/FLINK-40572) and follows up on the remaining work discussed in [#4520](https://github.com/apache/flink-cdc/pull/4520). Previously, the model argument of an AI function had to be a string literal. The parser extracted the model name before execution, and `JaninoCompiler` rewrote it to a pre-bound model client variable. As a result, expressions such as columns, `IF`, and `CASE` could not be used to select an AI model dynamically. This PR evaluates the model argument for each record and resolves the selected model at runtime. It allows a pipeline to choose among the models declared in `pipeline.model` based on record contents. ## Brief change log - Add an internal `AiModelClientResolver` for resolving declared model clients at runtime. - Evaluate the model argument as a regular `STRING` expression for every record. - Support dynamic model selection through columns, `IF`, and `CASE` expressions. - Remove the static model extraction and capability validation from the parser and composer. - Remove the special model-literal rewriting logic from `JaninoCompiler`. - Validate null, undeclared, and capability-incompatible models when the AI function is invoked. - Preserve null-input short-circuit behavior without resolving the model. - Preserve the precedence of user-defined functions with the same name. - Update the English and Chinese AI model documentation. --- ## Verifying this change This change added and updated tests and can be verified as follows: - Updated `AiFunctionsTest` to cover runtime model resolution, missing models, null model names, incompatible capabilities, and null-input short-circuiting. - Updated `AiFunctionParserTest` to cover dynamic model expressions and user-defined function precedence. - Updated `FlinkPipelineAiFunctionITCase` to verify dynamic model selection in a running pipeline. - Verified the runtime and composer tests with Flink 1.20. - Verified the runtime and composer tests with Flink 2.x using the `flink2` profile. - Verified code formatting with `mvn spotless:check`. ## Documentation - Does this pull request introduce a new feature? yes - If yes, how is the feature documented? English and Chinese documentation --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes (OpenAI Codex) Generated-by: OpenAI Codex (GPT-5) ``` -- 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]
