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

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

                Author: ASF GitHub Bot
            Created on: 06/Jan/20 21:44
            Start Date: 06/Jan/20 21:44
    Worklog Time Spent: 10m 
      Work Description: iemejia commented on pull request #10492: [BEAM-9041, 
BEAM-9042] SchemaCoder equals should not rely on from/toRowFunction equality
URL: https://github.com/apache/beam/pull/10492#discussion_r363497491
 
 

 ##########
 File path: 
sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/AvroUtils.java
 ##########
 @@ -431,7 +431,20 @@ public static GenericRecord toGenericRecord(
    */
   public static SerializableFunction<Row, GenericRecord> 
getRowToGenericRecordFunction(
       @Nullable org.apache.avro.Schema avroSchema) {
-    return g -> toGenericRecord(g, avroSchema);
+    return new RowToGenericRecordFn(avroSchema);
+  }
+
+  private static class RowToGenericRecordFn implements 
SerializableFunction<Row, GenericRecord> {
+    private final transient org.apache.avro.Schema avroSchema;
+
+    RowToGenericRecordFn(@Nullable org.apache.avro.Schema avroSchema) {
+      this.avroSchema = avroSchema;
+    }
+
+    @Override
+    public GenericRecord apply(Row input) {
+      return toGenericRecord(input, avroSchema);
+    }
 
 Review comment:
   This is a second different issue about capture of Avro schema on 
serialization so not really related to equals. As explained above I put both 
together because I use equality to validate the roundtrip of 
serialization/deserialization.
 
----------------------------------------------------------------
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:
us...@infra.apache.org


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

    Worklog Id:     (was: 367013)
    Time Spent: 0.5h  (was: 20m)

> SchemaCoder equals should not rely on from/toRowFunction equality
> -----------------------------------------------------------------
>
>                 Key: BEAM-9041
>                 URL: https://issues.apache.org/jira/browse/BEAM-9041
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-java-core
>            Reporter: Ismaël Mejía
>            Assignee: Ismaël Mejía
>            Priority: Minor
>             Fix For: 2.18.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> SchemaCoder equals implementation relies on SerializableFunction equals 
> method, this is error-prone because users rarely implement the equals method 
> for a SerializableFunction. One alternative would be to rely on bytes 
> equality for this.



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

Reply via email to