Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.UUID;
Expand Down Expand Up @@ -135,7 +136,7 @@ void convertDiff() {
expectedPartitionToReplacedFileIds.put(
partitionPath1, Arrays.asList(fileName3, fileIdForFile4));
expectedPartitionToReplacedFileIds.put(partitionPath2, Collections.singletonList(fileName5));
assertEquals(
assertEqualsIgnoreOrder(
expectedPartitionToReplacedFileIds, replaceMetadata.getPartitionToReplacedFileIds());
Comment on lines +139 to 140
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified to ?
assertEquals(new HashSet<>(expectedPartitionToReplacedFileIds), new HashSet<>(replaceMetadata.getPartitionToReplacedFileIds()))

Copy link
Contributor Author

@ashvina ashvina Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @vinishjail97 . I didn't understand. Have you tried this change, does it compile?

  1. expectedPartitionToReplacedFileIds is a HashMap which cannnot be used to initialize a HashSet
  2. The order mismatch happens in the values of the HashMaps, where the values are Lists. The tests fails when the values in the lists are out of order. Please see the example in the bug report for reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, could you please confirm that Hudi does not depend on the order of the files in the lists?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad didn't see it was Map<String, List<String>>, change LGTM.

Hudi does not depend on the order of the files in the lists?
Yes it does not depend on order.


// validate added files
Expand All @@ -146,6 +147,16 @@ void convertDiff() {
assertWriteStatusesEquivalent(expectedWriteStatuses, replaceMetadata.getWriteStatuses());
}

private void assertEqualsIgnoreOrder(
Map<String, List<String>> expected, Map<String, List<String>> actual) {
for (Map.Entry<String, List<String>> entry : expected.entrySet()) {
List<?> expectedList = entry.getValue();
List<?> actualList = actual.get(entry.getKey());
assertEquals(expectedList.size(), actualList.size());
assertEquals(new HashSet<>(expectedList), new HashSet<>(actualList));
}
}

@Test
void extractSnapshotChanges_emptyTargetTable() throws IOException {
String tableBasePath = tempDir.resolve(UUID.randomUUID().toString()).toString();
Expand Down