You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/07/16 06:07:32 UTC

[GitHub] [iceberg] szehon-ho commented on a diff in pull request #4142: [Core] Add utility to print an Iceberg table metadata

szehon-ho commented on code in PR #4142:
URL: https://github.com/apache/iceberg/pull/4142#discussion_r922638506


##########
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:
   Done.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org