twalthr opened a new pull request, #30019:
URL: https://github.com/apache/flink/pull/30019

   ## What is the purpose of the change
   
   Built-in functions of the `BuiltInFunctionDefinition` stack and 
`BuiltInSqlFunction` can be versioned, so that a compiled plan keeps the 
runtime behavior it was compiled with. Some operators cannot use this mechanism 
because Calcite references them directly, for example 
`SqlStdOperatorTable.ITEM` in the parser and in `RexBuilder`.
   
   This PR adds the framework to version such operators. It doesn't version any 
operator yet; the first one will follow in a separate PR.
   
   ## Brief change log
   
     - Rename the interface `BuiltInSqlOperator` to `VersionedSqlOperator`.
     - Add a class `BuiltInSqlOperator` that wraps an existing `SqlOperator` 
under a versioned name such as `$ITEM$1`, and otherwise delegates to the 
wrapped operator. Like `BuiltInFunctionDefinition`, it can be marked as 
internal so that it is not exposed when listing functions.
     - Add `FlinkSqlOperatorTable.VERSIONED_OPERATORS`, which maps an operator 
that is not versioned itself to the `BuiltInSqlOperator` of its latest version. 
`VersionedSqlOperator#toQualifiedName` consults it, so a compiled plan contains 
e.g. `$ITEM$2` for `ITEM`. Older versions are registered in 
`FlinkSqlOperatorTable` under their versioned name and are restored by the 
existing lookup. The JavaDoc of `VERSIONED_OPERATORS` describes the steps and 
shows them as pseudo code.
     - Relax the naming convention of internal functions to allow the symbols 
of Calcite's standard operators (`% & * + - / < = > ^ |`). Compiled plans 
already contain names such as `$<=$1` or `$+$1`.
     - Fix `BuiltInSqlFunction.Builder#internal()`, which always failed with 
"Internal function must not define a version." because the constructor 
validated the raw version instead of the effective one.
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - `BuiltInSqlOperatorTest` covers versioned and internal operators, the 
naming convention including symbol names, invalid versions, and that type 
inference is delegated to the wrapped operator.
     - `BuiltInSqlFunctionTest` covers versioned and internal functions, 
including the fix for `internal()`.
     - The existing `RexNodeJsonSerdeTest` and restore tests pass unchanged; 
the plan format does not change since `VERSIONED_OPERATORS` is empty.
     - A proof of concept that versions `ITEM` on top of this framework 
restored the existing `$ITEM$1` plans of `CalcRestoreTest`, 
`TableSourceScanRestoreTest`, and `TemporalJoinRestoreTest` successfully.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: no
     - The serializers: no
     - The runtime per-record code paths (performance sensitive): no
     - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
     - If yes, how is the feature documented? not applicable
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code (Opus 5.5)
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to