reuvenlax commented on code in PR #26320:
URL: https://github.com/apache/beam/pull/26320#discussion_r1234703649


##########
runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/util/AvroCoderCloudObjectTranslator.java:
##########
@@ -20,38 +20,41 @@
 import org.apache.avro.Schema;
 import org.apache.beam.runners.core.construction.SdkComponents;
 import org.apache.beam.sdk.extensions.avro.coders.AvroCoder;
+import org.apache.beam.sdk.extensions.avro.io.AvroDatumFactory;
+import org.apache.beam.sdk.util.SerializableUtils;
+import org.apache.beam.sdk.util.StringUtils;
 
 /** A {@link CloudObjectTranslator} for {@link AvroCoder}. */
 @SuppressWarnings({
   "rawtypes" // TODO(https://github.com/apache/beam/issues/20447)
 })
 class AvroCoderCloudObjectTranslator implements 
CloudObjectTranslator<AvroCoder> {
-  private static final String TYPE_FIELD = "type";
+  private static final String DATUM_FACTORY_FIELD = "datum_factory";
   private static final String SCHEMA_FIELD = "schema";
-  private static final String REFLECT_API_FIELD = "reflect_api";
 
   @Override
   public CloudObject toCloudObject(AvroCoder target, SdkComponents 
sdkComponents) {
     CloudObject base = CloudObject.forClass(AvroCoder.class);
+    byte[] serializedDatumFactory =
+        SerializableUtils.serializeToByteArray(target.getDatumFactory());
+    Structs.addString(
+        base, DATUM_FACTORY_FIELD, 
StringUtils.byteArrayToJsonString(serializedDatumFactory));
     Structs.addString(base, SCHEMA_FIELD, target.getSchema().toString());
-    Structs.addString(base, TYPE_FIELD, target.getType().getName());
-    Structs.addBoolean(base, REFLECT_API_FIELD, target.useReflectApi());
     return base;
   }
 
   @Override
   public AvroCoder<?> fromCloudObject(CloudObject cloudObject) {

Review Comment:
   Yes, I think this is problematic. Any pipeline that uses AvroCoder will now 
fail to update, which is something we generally avoid.



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