Yoshi Nagasaki
08/22/2025, 3:25 PMADD operator for this purpose: the Flink job would take care of summing many events for a given key over a window and then incrementally write the sum to the existing total in DDB. However, this requires the use of UpdateItem, which is not supported by the DDB client's BatchWriteItem operation, which is currently the only supported request operation by the DDB connector for Java. (Sorry if I'm posting this question in the wrong channel, but I didn't see any more appropriate-sounding one... and this question/problem should translate to other clients too.) DDB supports UpdateItem (and PutItem and DeleteItem) for TransactWriteItems requests, which uses DDB transactions to atomically write updates across multiple tables/table entries. Looking through the connector code, it seems pretty straightforward to add support for an "update" operation by using DDB transactions -- these are more expensive operations (in terms of latency and consumed capacity units) so it might not make sense to make them the "default" request type, but it would enable functionality that doesn't currently exist in the connector.
So my questions are:
1. Is there a specific reason this functionality was not added in the first place (i.e. "because it's a bad idea", "because it tested poorly", "because there's an easier way to do this that works fine")?
2. Is there an easier way to do this that works fine?
Chatting with a co-worker who is also delving into Flink for a different project, he mentioned that it should work fine to explicitly read the existing value from the DDB table in the Flink job, add the delta, and write it back -- since the stream is keyed by the metric key, only one node should process/sum the records for that key, so there should be no race condition (is this true?). Even so, it seems like a decent amount of extra work (and extra network calls to read in the values) in the Flink job for what seemingly could just be handled by DDB itself if the TransactWriteItem API is added to the connector. Am I missing something here?
Sorry for the wall of text and thanks!Yoshi Nagasaki
09/03/2025, 9:57 PMUpdateItem requests using DDB transactions, which is nice because DDB transactions can handle up to 100 individual items.
The Flink docs assert that as long as you setup checkpointing in Flink and your source is replayable and your sink is transactional or idempotent, then you get exactly-once semantics end-to-end.
It was pretty straightforward to implement the custom DDB sink, since there are base classes that do most of the heavy lifting for you (see https://flink.apache.org/2022/03/16/the-generic-asynchronous-base-sink/), and the existing DDB sink code serves as an example implementation. The only slight wrinkle was that batches could contain entries for the same DDB key, which DDB doesn't allow, so I had to merge same-key entries before constructing the TransactWriteItems request.
Based on what I've read and my understand of Flink so far, this should suffice; my approach may have to change once I start testing, so YMMV πNishtha Bhattacharjee
09/18/2025, 6:51 AMYoshi Nagasaki
09/18/2025, 6:07 PMNishtha Bhattacharjee
09/19/2025, 7:48 PM