From b6666d3d3cfc999ac2d37bc801ea5531cbd82fe0 Mon Sep 17 00:00:00 2001 From: tcodehuber Date: Wed, 13 Dec 2023 00:04:28 +0800 Subject: [PATCH] [AMORO-2260] Show the format version of Iceberg Table Signed-off-by: tcodehuber --- .../MixedAndIcebergTableDescriptor.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ams/server/src/main/java/com/netease/arctic/server/dashboard/MixedAndIcebergTableDescriptor.java b/ams/server/src/main/java/com/netease/arctic/server/dashboard/MixedAndIcebergTableDescriptor.java index 56850d0d33..e70abae7fe 100644 --- a/ams/server/src/main/java/com/netease/arctic/server/dashboard/MixedAndIcebergTableDescriptor.java +++ b/ams/server/src/main/java/com/netease/arctic/server/dashboard/MixedAndIcebergTableDescriptor.java @@ -53,6 +53,7 @@ import com.netease.arctic.utils.ArcticDataFiles; import org.apache.commons.collections.CollectionUtils; import org.apache.iceberg.ContentFile; +import org.apache.iceberg.HasTableOperations; import org.apache.iceberg.IcebergFindFiles; import org.apache.iceberg.PartitionSpec; import org.apache.iceberg.Snapshot; @@ -102,6 +103,7 @@ public List supportFormat() { @Override public ServerTableMeta getTableDetail(AmoroTable amoroTable) { ArcticTable table = getTable(amoroTable); + String tableFormat = decorateTableFormat(amoroTable); // set basic info TableBasicInfo tableBasicInfo = getTableBasicInfo(table); ServerTableMeta serverTableMeta = getServerTableMeta(table); @@ -150,11 +152,24 @@ public ServerTableMeta getTableDetail(AmoroTable amoroTable) { tableSummary.put("size", byteToXB(tableSize)); tableSummary.put("file", tableFileCnt); tableSummary.put("averageFile", byteToXB(tableFileCnt == 0 ? 0 : tableSize / tableFileCnt)); - tableSummary.put("tableFormat", AmsUtil.formatString(amoroTable.format().name())); + tableSummary.put("tableFormat", tableFormat); serverTableMeta.setTableSummary(tableSummary); return serverTableMeta; } + private String decorateTableFormat(AmoroTable table) { + StringBuilder sb = new StringBuilder(); + sb.append(AmsUtil.formatString(table.format().name())); + if (table.format().equals(TableFormat.ICEBERG)) { + int formatVersion = + ((HasTableOperations) table.originalTable()).operations().current().formatVersion(); + sb.append("(V"); + sb.append(formatVersion); + sb.append(")"); + } + return sb.toString(); + } + private Long snapshotIdOfTableRef(Table table, String ref) { if (ref == null) { ref = SnapshotRef.MAIN_BRANCH;