[ 
https://issues.apache.org/jira/browse/BEAM-8374?focusedWorklogId=400881&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-400881
 ]

ASF GitHub Bot logged work on BEAM-8374:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 10/Mar/20 17:35
            Start Date: 10/Mar/20 17:35
    Worklog Time Spent: 10m 
      Work Description: lukecwik commented on pull request #9758: [BEAM-8374] 
Enable returning missing PublishResult fields in SnsIO.Write
URL: https://github.com/apache/beam/pull/9758#discussion_r390486072
 
 

 ##########
 File path: 
sdks/java/io/amazon-web-services/src/main/java/org/apache/beam/sdk/io/aws/sns/SnsIO.java
 ##########
 @@ -257,12 +269,37 @@ public Write withResultOutputTag(TupleTag<PublishResult> 
results) {
       return builder().setResultOutputTag(results).build();
     }
 
+    /**
+     * Encode the full {@code PublishResult} object, including 
sdkResponseMetadata and
+     * sdkHttpMetadata but excluding the HTTP response headers.
+     */
+    public Write withFullPublishResultNoHeaders() {
+      return 
builder().setCoder(PublishResultCoders.fullPublishResultNoHeaders()).build();
+    }
+
+    /**
+     * Encode the full {@code PublishResult} object, including 
sdkResponseMetadata and
+     * sdkHttpMetadata with the HTTP response headers.
+     */
+    public Write withFullPublishResultIncludingHeaders() {
+      return 
builder().setCoder(PublishResultCoders.fullPublishResultIncludingHeaders()).build();
+    }
+
+    /** Encode the {@code PublishResult} with the given coder. */
+    public Write withPublishResultCoder(Coder<PublishResult> coder) {
+      return builder().setCoder(coder).build();
+    }
+
     @Override
     public PCollectionTuple expand(PCollection<PublishRequest> input) {
       checkArgument(getTopicName() != null, "withTopicName() is required");
-      return input.apply(
-          ParDo.of(new SnsWriterFn(this))
-              .withOutputTags(getResultOutputTag(), TupleTagList.empty()));
+      PCollectionTuple result =
+          input.apply(
+              ParDo.of(new SnsWriterFn(this))
+                  .withOutputTags(getResultOutputTag(), TupleTagList.empty()));
+      Optional.ofNullable(getCoder())
+          .ifPresent(coder -> 
result.get(getResultOutputTag()).setCoder(coder));
 
 Review comment:
   nit: It is much easier for someone to understand the following logic:
   ```suggestion
         if (getCoder() != null) {
           result.get(getResultOutputTag()).setCoder(coder);
         }
   ```
 
----------------------------------------------------------------
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:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 400881)
    Time Spent: 6.5h  (was: 6h 20m)

> PublishResult returned by SnsIO is missing sdkResponseMetadata and 
> sdkHttpMetadata
> ----------------------------------------------------------------------------------
>
>                 Key: BEAM-8374
>                 URL: https://issues.apache.org/jira/browse/BEAM-8374
>             Project: Beam
>          Issue Type: Bug
>          Components: io-java-aws
>    Affects Versions: 2.13.0, 2.14.0, 2.15.0
>            Reporter: Jonothan Farr
>            Assignee: Jonothan Farr
>            Priority: Minor
>          Time Spent: 6.5h
>  Remaining Estimate: 0h
>
> Currently the PublishResultCoder in SnsIO only serializes the messageId field 
> so the PublishResult returned by Beam returns null for 
> getSdkResponseMetadata() and getSdkHttpMetadata(). This makes it impossible 
> to check the HTTP status for errors, which is necessary since this is not 
> handled in SnsIO.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to