Abacn commented on code in PR #25701:
URL: https://github.com/apache/beam/pull/25701#discussion_r1123994353


##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/datastore/DatastoreV1.java:
##########
@@ -1542,12 +1542,26 @@ public void startBundle(StartBundleContext c) {
       }
     }
 
+    private static com.google.datastore.v1.Key getKey(Mutation m) {
+      if (m.hasUpsert()) {
+        return m.getUpsert().getKey();
+      } else if (m.hasInsert()) {
+        return m.getInsert().getKey();
+      } else if (m.hasDelete()) {
+        return m.getDelete();
+      } else if (m.hasUpdate()) {
+        return m.getUpdate().getKey();
+      } else {
+        throw new IllegalArgumentException(String.format("Mutation %s is not 
valid.", m));

Review Comment:
   Are these 4 cases exhaustive? I also see `OPERATION_NOT_SET` in Mutation's 
source code. Maybe just add a warning and return an empty Key? Otherwise LGTM.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to