ahmedabu98 opened a new issue, #26695:
URL: https://github.com/apache/beam/issues/26695

   ### What happened?
   
   I was writing a test that checked for the equality of Beam Rows with a BYTES 
field and saw that Rows with the same bytes value are not seen as equal by 
PAssert::containsInAnyOrder.
   
   To reproduce:
   ```
   Schema schema = Schema.of(Schema.Field.of("bytes", Schema.FieldType.BYTES));
   ByteBuffer val = ByteBuffer.wrap("a".getBytes(StandardCharsets.UTF_8));
   
   Row row1 = Row.withSchema(schema).withFieldValue("bytes", val).build();
   Row row2 = Row.withSchema(schema).withFieldValue("bytes", val).build();
   
   List<Row> actual = Arrays.asList(row1);
   List<Row> expected = Arrays.asList(row2);
   System.out.println(row1.equals(row2)); // outputs true
   
   // Use Hamcrest assertThat and containsInAnyOrder
   assertThat(actual, containsInAnyOrder(expected)); // fails with error
   ```
   
   PAssert's containsInAnyOrder ultimately [uses Hamcrest's 
containsInAnyOrder](https://github.com/apache/beam/blob/9cf5946d461d986da9131675f73bf6d0ad53031e/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/PAssert.java#L1690)
 to perform the check. Drilling down into this method, it eventually does a 
obj1.equals(obj2) check on each object. However, when reproducing, using 
`.equals()`  by itself works as expected.
   
   ### Issue Priority
   
   Priority: 3 (minor)
   
   ### Issue Components
   
   - [ ] Component: Python SDK
   - [X] Component: Java SDK
   - [ ] Component: Go SDK
   - [ ] Component: Typescript SDK
   - [ ] Component: IO connector
   - [ ] Component: Beam examples
   - [ ] Component: Beam playground
   - [ ] Component: Beam katas
   - [ ] Component: Website
   - [ ] Component: Spark Runner
   - [ ] Component: Flink Runner
   - [ ] Component: Samza Runner
   - [ ] Component: Twister2 Runner
   - [ ] Component: Hazelcast Jet Runner
   - [ ] Component: Google Cloud Dataflow Runner


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