Skip to content

Commit

Permalink
[AMORO-2260] Show the format version of iceberg table (apache#2425)
Browse files Browse the repository at this point in the history
[AMORO-2260] Show the format version of Iceberg Table

Signed-off-by: tcodehuber <tcodehuber@gmail.com>
  • Loading branch information
tcodehuber authored and ShawHee committed Dec 29, 2023
1 parent e58e75f commit 9190e37
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -102,6 +103,7 @@ public List<TableFormat> 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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9190e37

Please sign in to comment.