Hi Zack, Flink would invoke the sink operator’s processElement (or SinkFunction.invoke(), etc) when it collects a record to be written out to the external system, and invoke the operator’s snapshotState() method when checkpointing. Buffering and flushing are regarded as internal implementations of the sink operator itself, and Flink infra has little knowledge of them. So if you found a buffering mechanism in the TableAPI sink operator, you should also be able to found the flushing mechanism somewhere in the operator’s codes.
From my little experience, if an operator has a buffering optimization and it needs to achieve exactly-once semantics, it should flush the buffer out to downstream or external systems before checkpointing, or store the buffered records into states. Besides, Flink does provide some built-in helper classes to help sinks better get prepared before checkpoints, like
https://nightlies.apache.org/flink/flink-docs-master/api/java/org/apache/flink/streaming/api/functions/sink/TwoPhaseCommitSinkFunction.html
You may also refer to this article
https://flink.apache.org/2018/02/28/an-overview-of-end-to-end-exactly-once-processing-in-apache-flink-with-apache-kafka-too/