stevenzwu commented on a change in pull request #2989:
URL: https://github.com/apache/iceberg/pull/2989#discussion_r697797868



##########
File path: flink/src/test/java/org/apache/iceberg/flink/SimpleDataUtil.java
##########
@@ -259,4 +265,37 @@ public static StructLikeSet actualRowSet(Table table, Long 
snapshotId, String...
 
     return dataFiles;
   }
+
+  public static Map<Long, List<DataFile>> snapshotToDataFiles(
+      Table table)
+      throws IOException {
+    table.refresh();
+    Map<Long, List<DataFile>> res = Maps.newHashMap();
+    List<ManifestFile> manifestFiles = table.currentSnapshot().allManifests();
+    for (ManifestFile mf : manifestFiles) {
+      try (ManifestReader<DataFile> reader = ManifestFiles.read(mf, 
table.io())) {
+        List<DataFile> dataFiles = IteratorUtils.toList(reader.iterator());
+        if (res.containsKey(mf.snapshotId())) {
+          res.get(mf.snapshotId()).addAll(dataFiles);
+        } else {
+          res.put(mf.snapshotId(), dataFiles);
+        }
+      }
+    }
+    return res;
+  }
+
+  public static List<DataFile> matchingPartitions(
+      List<DataFile> dataFiles, PartitionSpec partitionSpec, Map<String, 
Object> partitionValues) {
+    Types.StructType spec = partitionSpec.partitionType();
+    Record partitionRecord = GenericRecord.create(spec).copy(partitionValues);
+    StructLikeWrapper expected = StructLikeWrapper

Review comment:
       `PartitionData` implements the `equals` method. we can construct 
`PartitionData` using this API from `DataFiles` class. not sure if it is 
better. but at least it is more specific.
   ```
     public static PartitionData copy(PartitionSpec spec, StructLike partition) 
{
       return copyPartitionData(spec, partition, null);
     }
   ```




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to