chamikaramj commented on code in PR #31451:
URL: https://github.com/apache/beam/pull/31451#discussion_r1621341887


##########
sdks/java/core/src/main/java/org/apache/beam/sdk/util/construction/TransformUpgrader.java:
##########
@@ -184,26 +203,33 @@ RunnerApi.Pipeline updateTransformViaTransformService(
     if (transformToUpgrade == null) {
       throw new IllegalArgumentException("Could not find a transform with the 
ID " + transformId);
     }
-    ByteString configRowBytes =
-        
transformToUpgrade.getAnnotationsOrThrow(PTransformTranslation.CONFIG_ROW_KEY);
-    ByteString configRowSchemaBytes =
-        
transformToUpgrade.getAnnotationsOrThrow(PTransformTranslation.CONFIG_ROW_SCHEMA_KEY);
-    SchemaApi.Schema configRowSchemaProto =
-        SchemaApi.Schema.parseFrom(configRowSchemaBytes.toByteArray());
-
-    ExternalTransforms.ExternalConfigurationPayload payload =
-        ExternalTransforms.ExternalConfigurationPayload.newBuilder()
-            .setSchema(configRowSchemaProto)
-            .setPayload(configRowBytes)
-            .build();
+
+    byte[] payloadBytes = null;
+
+    if 
(!transformToUpgrade.getSpec().getUrn().equals(BeamUrns.getUrn(SCHEMA_TRANSFORM)))
 {
+      ByteString configRowBytes =
+          
transformToUpgrade.getAnnotationsOrThrow(PTransformTranslation.CONFIG_ROW_KEY);
+      ByteString configRowSchemaBytes =
+          
transformToUpgrade.getAnnotationsOrThrow(PTransformTranslation.CONFIG_ROW_SCHEMA_KEY);
+      SchemaApi.Schema configRowSchemaProto =
+          SchemaApi.Schema.parseFrom(configRowSchemaBytes.toByteArray());
+      payloadBytes =
+          ExternalTransforms.ExternalConfigurationPayload.newBuilder()
+              .setSchema(configRowSchemaProto)
+              .setPayload(configRowBytes)
+              .build()
+              .toByteArray();
+    } else {
+      payloadBytes = transformToUpgrade.getSpec().getPayload().toByteArray();
+    }
 
     RunnerApi.PTransform.Builder ptransformBuilder =
         RunnerApi.PTransform.newBuilder()
             .setUniqueName(transformToUpgrade.getUniqueName() + "_external")
             .setSpec(
                 RunnerApi.FunctionSpec.newBuilder()
                     .setUrn(transformToUpgrade.getSpec().getUrn())
-                    .setPayload(ByteString.copyFrom(payload.toByteArray()))
+                    .setPayload(ByteString.copyFrom(payloadBytes))

Review Comment:
   Yes. This is the protocol for the ExpansionRequest, the payload depends on 
the URN.
   
   If the URN is "BeamUrns.getUrn(SCHEMA_TRANSFORM)" payload should be 
"SchemaTransformPayload".
   
   
https://github.com/apache/beam/blob/c90fd8320a571573e9375318818bdb1a7c15d421/model/pipeline/src/main/proto/org/apache/beam/model/pipeline/v1/external_transforms.proto#L57



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