Airblader opened a new pull request #16046:
URL: https://github.com/apache/flink/pull/16046
## What is the purpose of the change
This change introduces the built-in function
`CURRENT_WATERMARK(<rowtimeAttribute>)` which returns the current watermark.
The function returns it with the same type as the given rowtime attribute, i.e.
TIMESTAMP / TIMESTAMP_LTZ, but it (i) removes the rowtime kind, (ii) sets the
precision to 3 and (iii) makes it nullable.
If no watermark has been emitted yet, `NULL` is returned instead. This was a
deliberate decision (see discussion on JIRA) as it is a better fit for
high-level APIs like SQL where constants such as `Long.MIN_VALUE` are
inaccessible.
## Brief change log
* Extend the new built-in function stack to support a hybrid mode where we
can make use of the new stack, but not actually implement the function through
a runtime class. We need to code generate this function as the regular
user-defined function stack does not have access to the `TimerService` and thus
the current watermark.
* Implement `CURRENT_WATERMARK()` and expose it in SQL, Table API and
PyFlink.
* Add `CURRENT_WATERMARK` to the documentation.
## Verifying this change
This change added tests and can be verified as follows:
* `org.apache.flink.table.planner.runtime.stream.sql.CalcITCase` adds test
cases both for a functional scenario as well as an error scenario.
* `TypeStrategiesTest` and `CurrentWatermarkInputTypeStrategyTest` provide
tests for the input and output type strategies
## 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)`: yes (SQL)
- 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/Mesos, ZooKeeper: no
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? yes
- If yes, how is the feature documented? docs, JavaDocs
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]