Airblader commented on a change in pull request #16046: URL: https://github.com/apache/flink/pull/16046#discussion_r649080052
########## File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/Expressions.java ########## @@ -211,6 +211,27 @@ public static ApiExpression currentTimestamp() { return apiCall(BuiltInFunctionDefinitions.CURRENT_TIMESTAMP); } + /** + * Returns the current watermark for the given rowtime attribute, or {@code NULL} if no + * watermark has been emitted yet. + * + * <p>The function returns the watermark with the same type as the rowtime attribute, but with + * an adjusted precision of 3. For example, if the rowtime attribute is {@link + * DataTypes#TIMESTAMP_LTZ(int) TIMESTAMP_LTZ(9)}, the function will return {@link + * DataTypes#TIMESTAMP_LTZ(int) TIMESTAMP_LTZ(3)}. + * + * <p>If no watermark has been emitted yet, the function will return {@code NULL}. Users must + * take care of this when comparing against it, e.g. in order to filter out late data you can + * use + * + * <pre>{@code + * WHERE CURRENT_WATERMARK(ts) IS NULL OR ts > CURRENT_WATERMARK(ts) + * }</pre> + */ + public static ApiExpression currentWatermark(Object rowtimeAttribute) { Review comment: I think I like the prefix version a bit better here (though it's a close call). The advantages of the infix notation are really just all of the general ones – nothing that applies to this scenario, specifically, I think. Since the watermark isn't really part of the time attribute, but rather just defined using it, I slightly prefer the prefix version. -- 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: us...@infra.apache.org