flyrain commented on a change in pull request #4142:
URL: https://github.com/apache/iceberg/pull/4142#discussion_r814170215



##########
File path: core/src/main/java/org/apache/iceberg/ReachableFileUtil.java
##########
@@ -114,4 +119,54 @@ private static TableMetadata 
findFirstExistentPreviousMetadata(List<MetadataLogE
     }
     return manifestListLocations;
   }
+
+  /**
+   * Emits a human-readable metadata graph of the Iceberg table's current 
snapshot
+   * @param table Iceberg table
+   * @param out output stream to emit to
+   */
+  public static void printTable(Table table, PrintStream out) {
+    
out.println("------------------------------------------------------------");
+    out.println("Table " + table.name());
+    
out.println("------------------------------------------------------------");
+    printSnapshot(table, table.currentSnapshot(), out);
+  }
+
+  /**
+   * Emits a human-readable metadata graph of the given snapshot
+   * @param table Iceberg table
+   * @param snapshot Iceberg table snapshot
+   * @param out output print stream to emit to
+   */
+  public static void printSnapshot(Table table, Snapshot snapshot, PrintStream 
out) {
+    out.println(snapshot);
+    Iterator<ManifestFile> allManifests = snapshot.allManifests().iterator();
+    while (allManifests.hasNext()) {
+      ManifestFile mf = allManifests.next();
+      out.println(" \\---" + mf);
+
+      if (mf.content().equals(ManifestContent.DATA)) {

Review comment:
       Can we create a new read method which take `FileType` as a parameter? So 
that we don't have to distinguish datafile and deletefile.
   ```
   ManifestFiles.read(ManifestFile manifest, FileIO io, Map<Integer, 
PartitionSpec> specsById, FileType fileType)
   ```




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