You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/08/31 14:30:03 UTC

[GitHub] [beam] dennisylyung commented on a change in pull request #12583: [BEAM-10706] Fix duplicate key error in DynamoDBIO.Write

dennisylyung commented on a change in pull request #12583:
URL: https://github.com/apache/beam/pull/12583#discussion_r480169412



##########
File path: sdks/java/io/amazon-web-services/src/main/java/org/apache/beam/sdk/io/aws/dynamodb/DynamoDBIO.java
##########
@@ -450,12 +459,35 @@ public void startBundle(StartBundleContext context) {
       public void processElement(ProcessContext context) throws Exception {
         final KV<String, WriteRequest> writeRequest =
             (KV<String, WriteRequest>) spec.getWriteItemMapperFn().apply(context.element());
+        if (spec.getOverwriteByPKeys() != null) {
+          removeDupPKeysRequestsIfAny(writeRequest.getValue());
+        }
         batch.add(writeRequest);
         if (batch.size() >= BATCH_SIZE) {
           flushBatch();
         }
       }
 
+      private void removeDupPKeysRequestsIfAny(WriteRequest request) {

Review comment:
       I think the later event is more preferred, although Apache beam do not have strict ordering. Not sure why the AWS Python SDK is implemented this way. I will try using something like a map. 




----------------------------------------------------------------
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:
users@infra.apache.org