diff --git a/amoro-ams/src/main/java/org/apache/amoro/server/dashboard/ServerTableDescriptor.java b/amoro-ams/src/main/java/org/apache/amoro/server/dashboard/ServerTableDescriptor.java index 4ffd7eee1a..2eb7da70e6 100644 --- a/amoro-ams/src/main/java/org/apache/amoro/server/dashboard/ServerTableDescriptor.java +++ b/amoro-ams/src/main/java/org/apache/amoro/server/dashboard/ServerTableDescriptor.java @@ -39,8 +39,6 @@ import org.apache.commons.lang3.tuple.Pair; import org.apache.iceberg.util.ThreadPools; -import javax.annotation.Nullable; - import java.util.HashMap; import java.util.List; import java.util.Map; @@ -82,7 +80,7 @@ public List getSnapshots( } public List getSnapshotDetail( - TableIdentifier tableIdentifier, String snapshotId, @Nullable String ref) { + TableIdentifier tableIdentifier, String snapshotId, String ref) { AmoroTable amoroTable = loadTable(tableIdentifier); FormatTableDescriptor formatTableDescriptor = formatDescriptorMap.get(amoroTable.format()); return formatTableDescriptor.getSnapshotDetail(amoroTable, snapshotId, ref); diff --git a/amoro-common/src/main/java/org/apache/amoro/table/descriptor/FormatTableDescriptor.java b/amoro-common/src/main/java/org/apache/amoro/table/descriptor/FormatTableDescriptor.java index 89473bc894..03bbea7938 100644 --- a/amoro-common/src/main/java/org/apache/amoro/table/descriptor/FormatTableDescriptor.java +++ b/amoro-common/src/main/java/org/apache/amoro/table/descriptor/FormatTableDescriptor.java @@ -22,8 +22,6 @@ import org.apache.amoro.TableFormat; import org.apache.commons.lang3.tuple.Pair; -import javax.annotation.Nullable; - import java.util.List; import java.util.concurrent.ExecutorService; @@ -49,7 +47,7 @@ List getSnapshots( /** Get the snapshot detail information of the {@link AmoroTable}. */ List getSnapshotDetail( - AmoroTable amoroTable, String snapshotId, @Nullable String ref); + AmoroTable amoroTable, String snapshotId, String ref); /** Get the DDL information of the {@link AmoroTable}. */ List getTableOperations(AmoroTable amoroTable); diff --git a/amoro-format-paimon/src/main/java/org/apache/amoro/formats/paimon/PaimonTableDescriptor.java b/amoro-format-paimon/src/main/java/org/apache/amoro/formats/paimon/PaimonTableDescriptor.java index a79b1a0073..d94ddc937d 100644 --- a/amoro-format-paimon/src/main/java/org/apache/amoro/formats/paimon/PaimonTableDescriptor.java +++ b/amoro-format-paimon/src/main/java/org/apache/amoro/formats/paimon/PaimonTableDescriptor.java @@ -63,8 +63,6 @@ import org.apache.paimon.utils.SnapshotManager; import org.jetbrains.annotations.NotNull; -import javax.annotation.Nullable; - import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -225,16 +223,17 @@ public List getSnapshots( @Override public List getSnapshotDetail( - AmoroTable amoroTable, String snapshotId, @Nullable String ref) { + AmoroTable amoroTable, String snapshotId, String ref) { FileStoreTable table = getTable(amoroTable); List amsDataFileInfos = new ArrayList<>(); long commitId = Long.parseLong(snapshotId); Snapshot snapshot; - if (ref != null) { + if (BranchManager.isMainBranch(ref) || table.branchManager().branchExists(ref)) { snapshot = table.snapshotManager().copyWithBranch(ref).snapshot(commitId); } else { - snapshot = table.snapshotManager().snapshot(commitId); + snapshot = table.tagManager().tag(ref); } + FileStore store = table.store(); FileStorePathFactory fileStorePathFactory = store.pathFactory(); ManifestList manifestList = store.manifestListFactory().create(); @@ -528,10 +527,8 @@ public List getTableTags(AmoroTable amoroTable) { public List getTableBranches(AmoroTable amoroTable) { FileStoreTable table = getTable(amoroTable); List branches = table.branchManager().branches(); - List branchInfos = branches.stream() - .filter(name -> !BranchManager.isMainBranch(name)) .map(name -> new TagOrBranchInfo(name, -1, -1, 0L, 0L, TagOrBranchInfo.BRANCH)) .collect(Collectors.toList()); branchInfos.add(TagOrBranchInfo.MAIN_BRANCH);