[ https://issues.apache.org/jira/browse/BEAM-4076?focusedWorklogId=122944&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-122944 ]
ASF GitHub Bot logged work on BEAM-4076: ---------------------------------------- Author: ASF GitHub Bot Created on: 13/Jul/18 16:39 Start Date: 13/Jul/18 16:39 Worklog Time Spent: 10m Work Description: apilloud commented on a change in pull request #5941: [BEAM-4076] Schema utilities for converting between types URL: https://github.com/apache/beam/pull/5941#discussion_r202401770 ########## File path: sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/Schema.java ########## @@ -182,6 +184,33 @@ public boolean equals(Object o) { && Objects.equals(getFields(), other.getFields()); } + /** Returns true if two Schemas have the same fields, but possibly in different orders. */ + public boolean equivalent(Schema other) { + List<Field> otherFields = + other + .getFields() + .stream() + .sorted(Comparator.comparing(Field::getName)) + .collect(Collectors.toList()); + List<Field> actualFields = + getFields() + .stream() + .sorted(Comparator.comparing(Field::getName)) + .collect(Collectors.toList()); + if (otherFields.size() != actualFields.size()) { Review comment: I'm pretty sure I've seen this function before on the whiteboard in an interview. It would be good to move this check before the sorts. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on 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: 122944) Time Spent: 9.5h (was: 9h 20m) > Schema followups > ---------------- > > Key: BEAM-4076 > URL: https://issues.apache.org/jira/browse/BEAM-4076 > Project: Beam > Issue Type: Improvement > Components: beam-model, dsl-sql, sdk-java-core > Reporter: Kenneth Knowles > Priority: Major > Time Spent: 9.5h > Remaining Estimate: 0h > > This umbrella bug contains subtasks with followups for Beam schemas, which > were moved from SQL to the core Java SDK and made to be type-name-based > rather than coder based. -- This message was sent by Atlassian JIRA (v7.6.3#76005)