This is an automated email from the ASF dual-hosted git repository.
czy006 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/amoro.git
The following commit(s) were added to refs/heads/master by this push:
new bbb406264 [AMORO-2842] Support list all paimon branch (#3093)
bbb406264 is described below
commit bbb406264a41450ad38e3567c62dd8685ad5c5b8
Author: big face cat <[email protected]>
AuthorDate: Fri Nov 1 11:21:03 2024 +0800
[AMORO-2842] Support list all paimon branch (#3093)
* Support list all paimon branch
* update
* Support list all paimon branch
---------
Co-authored-by: huyuanfeng <[email protected]>
Co-authored-by: ConradJam <[email protected]>
---
.../dashboard/MixedAndIcebergTableDescriptor.java | 4 +++-
.../server/dashboard/ServerTableDescriptor.java | 4 ++--
.../dashboard/controller/TableController.java | 5 +++-
.../table/descriptor/FormatTableDescriptor.java | 3 ++-
.../amoro/formats/hudi/HudiTableDescriptor.java | 4 +++-
.../formats/paimon/PaimonTableDescriptor.java | 27 +++++++++++++++++-----
amoro-web/src/services/table.service.ts | 5 ++--
.../src/views/tables/components/Snapshots.vue | 1 +
8 files changed, 39 insertions(+), 14 deletions(-)
diff --git
a/amoro-ams/src/main/java/org/apache/amoro/server/dashboard/MixedAndIcebergTableDescriptor.java
b/amoro-ams/src/main/java/org/apache/amoro/server/dashboard/MixedAndIcebergTableDescriptor.java
index 792a9170d..8b58d96dc 100644
---
a/amoro-ams/src/main/java/org/apache/amoro/server/dashboard/MixedAndIcebergTableDescriptor.java
+++
b/amoro-ams/src/main/java/org/apache/amoro/server/dashboard/MixedAndIcebergTableDescriptor.java
@@ -87,6 +87,8 @@ import org.apache.iceberg.util.SnapshotUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nullable;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -341,7 +343,7 @@ public class MixedAndIcebergTableDescriptor extends
PersistentBase
@Override
public List<PartitionFileBaseInfo> getSnapshotDetail(
- AmoroTable<?> amoroTable, String snapshotId) {
+ AmoroTable<?> amoroTable, String snapshotId, @Nullable String ref) {
MixedTable mixedTable = getTable(amoroTable);
List<PartitionFileBaseInfo> result = new ArrayList<>();
long commitId = Long.parseLong(snapshotId);
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 521d80f62..7b8ed7b8a 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
@@ -81,10 +81,10 @@ public class ServerTableDescriptor extends PersistentBase {
}
public List<PartitionFileBaseInfo> getSnapshotDetail(
- TableIdentifier tableIdentifier, String snapshotId) {
+ TableIdentifier tableIdentifier, String snapshotId, String ref) {
AmoroTable<?> amoroTable = loadTable(tableIdentifier);
FormatTableDescriptor formatTableDescriptor =
formatDescriptorMap.get(amoroTable.format());
- return formatTableDescriptor.getSnapshotDetail(amoroTable, snapshotId);
+ return formatTableDescriptor.getSnapshotDetail(amoroTable, snapshotId,
ref);
}
public List<DDLInfo> getTableOperations(TableIdentifier tableIdentifier) {
diff --git
a/amoro-ams/src/main/java/org/apache/amoro/server/dashboard/controller/TableController.java
b/amoro-ams/src/main/java/org/apache/amoro/server/dashboard/controller/TableController.java
index e00984084..00e212952 100644
---
a/amoro-ams/src/main/java/org/apache/amoro/server/dashboard/controller/TableController.java
+++
b/amoro-ams/src/main/java/org/apache/amoro/server/dashboard/controller/TableController.java
@@ -416,10 +416,13 @@ public class TableController {
String snapshotId = ctx.pathParam("snapshotId");
Integer page = ctx.queryParamAsClass("page",
Integer.class).getOrDefault(1);
Integer pageSize = ctx.queryParamAsClass("pageSize",
Integer.class).getOrDefault(20);
+ String ref = ctx.queryParamAsClass("ref", String.class).getOrDefault(null);
List<PartitionFileBaseInfo> result =
tableDescriptor.getSnapshotDetail(
- TableIdentifier.of(catalog, database,
tableName).buildTableIdentifier(), snapshotId);
+ TableIdentifier.of(catalog, database,
tableName).buildTableIdentifier(),
+ snapshotId,
+ ref);
int offset = (page - 1) * pageSize;
PageResult<PartitionFileBaseInfo> amsPageResult = PageResult.of(result,
offset, pageSize);
ctx.json(OkResponse.of(amsPageResult));
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 3c1126a8f..1e8bc62c2 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
@@ -48,7 +48,8 @@ public interface FormatTableDescriptor {
AmoroTable<?> amoroTable, String ref, OperationType operationType);
/** Get the snapshot detail information of the {@link AmoroTable}. */
- List<PartitionFileBaseInfo> getSnapshotDetail(AmoroTable<?> amoroTable,
String snapshotId);
+ List<PartitionFileBaseInfo> getSnapshotDetail(
+ AmoroTable<?> amoroTable, String snapshotId, String ref);
/** Get the DDL information of the {@link AmoroTable}. */
List<DDLInfo> getTableOperations(AmoroTable<?> amoroTable);
diff --git
a/amoro-format-hudi/src/main/java/org/apache/amoro/formats/hudi/HudiTableDescriptor.java
b/amoro-format-hudi/src/main/java/org/apache/amoro/formats/hudi/HudiTableDescriptor.java
index 8720958b0..0a50afb30 100644
---
a/amoro-format-hudi/src/main/java/org/apache/amoro/formats/hudi/HudiTableDescriptor.java
+++
b/amoro-format-hudi/src/main/java/org/apache/amoro/formats/hudi/HudiTableDescriptor.java
@@ -74,6 +74,8 @@ import org.apache.hudi.table.HoodieJavaTable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nullable;
+
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
@@ -246,7 +248,7 @@ public class HudiTableDescriptor implements
FormatTableDescriptor {
@Override
public List<PartitionFileBaseInfo> getSnapshotDetail(
- AmoroTable<?> amoroTable, String snapshotId) {
+ AmoroTable<?> amoroTable, String snapshotId, @Nullable String ref) {
HoodieJavaTable hoodieTable = (HoodieJavaTable) amoroTable.originalTable();
SyncableFileSystemView fileSystemView = hoodieTable.getHoodieView();
Map<String, Stream<FileSlice>> ptFsMap =
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 681b7e095..b21766219 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
@@ -24,7 +24,6 @@ import org.apache.amoro.AmoroTable;
import org.apache.amoro.TableFormat;
import org.apache.amoro.api.CommitMetaProducer;
import org.apache.amoro.process.ProcessStatus;
-import org.apache.amoro.shade.guava32.com.google.common.collect.ImmutableList;
import org.apache.amoro.shade.guava32.com.google.common.collect.Lists;
import org.apache.amoro.shade.guava32.com.google.common.collect.Maps;
import org.apache.amoro.shade.guava32.com.google.common.collect.Streams;
@@ -61,7 +60,9 @@ import org.apache.paimon.manifest.ManifestFileMeta;
import org.apache.paimon.manifest.ManifestList;
import org.apache.paimon.table.DataTable;
import org.apache.paimon.table.FileStoreTable;
+import org.apache.paimon.utils.BranchManager;
import org.apache.paimon.utils.FileStorePathFactory;
+import org.apache.paimon.utils.SnapshotManager;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
@@ -181,9 +182,10 @@ public class PaimonTableDescriptor implements
FormatTableDescriptor {
FileStoreTable table = getTable(amoroTable);
List<AmoroSnapshotsOfTable> snapshotsOfTables = new ArrayList<>();
Iterator<Snapshot> snapshots;
- if (PAIMON_MAIN_BRANCH_NAME.equals(ref)) {
+ if (table.branchManager().branchExists(ref) ||
BranchManager.isMainBranch(ref)) {
+ SnapshotManager snapshotManager =
table.snapshotManager().copyWithBranch(ref);
try {
- snapshots = table.snapshotManager().snapshots();
+ snapshots = snapshotManager.snapshots();
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -223,11 +225,17 @@ public class PaimonTableDescriptor implements
FormatTableDescriptor {
@Override
public List<PartitionFileBaseInfo> getSnapshotDetail(
- AmoroTable<?> amoroTable, String snapshotId) {
+ AmoroTable<?> amoroTable, String snapshotId, String ref) {
FileStoreTable table = getTable(amoroTable);
List<PartitionFileBaseInfo> amsDataFileInfos = new ArrayList<>();
long commitId = Long.parseLong(snapshotId);
- Snapshot snapshot = table.snapshotManager().snapshot(commitId);
+ Snapshot snapshot;
+ if (BranchManager.isMainBranch(ref) ||
table.branchManager().branchExists(ref)) {
+ snapshot =
table.snapshotManager().copyWithBranch(ref).snapshot(commitId);
+ } else {
+ snapshot = table.tagManager().tag(ref);
+ }
+
FileStore<?> store = table.store();
FileStorePathFactory fileStorePathFactory = store.pathFactory();
ManifestList manifestList = store.manifestListFactory().create();
@@ -531,7 +539,14 @@ public class PaimonTableDescriptor implements
FormatTableDescriptor {
@Override
public List<TagOrBranchInfo> getTableBranches(AmoroTable<?> amoroTable) {
- return ImmutableList.of(TagOrBranchInfo.MAIN_BRANCH);
+ FileStoreTable table = getTable(amoroTable);
+ List<String> branches = table.branchManager().branches();
+ List<TagOrBranchInfo> branchInfos =
+ branches.stream()
+ .map(name -> new TagOrBranchInfo(name, -1, -1, 0L, 0L,
TagOrBranchInfo.BRANCH))
+ .collect(Collectors.toList());
+ branchInfos.add(TagOrBranchInfo.MAIN_BRANCH);
+ return branchInfos;
}
@Override
diff --git a/amoro-web/src/services/table.service.ts
b/amoro-web/src/services/table.service.ts
index 8b83d71d6..309a05d47 100644
--- a/amoro-web/src/services/table.service.ts
+++ b/amoro-web/src/services/table.service.ts
@@ -127,14 +127,15 @@ export function getDetailBySnapshotId(
catalog: string
db: string
table: string
+ ref: string
snapshotId: string
page: number
pageSize: number
token?: string
},
) {
- const { catalog, db, table, snapshotId, page, pageSize, token } = params
- return
request.get(`api/ams/v1/tables/catalogs/${catalog}/dbs/${db}/tables/${table}/snapshots/${snapshotId}/detail`,
{ params: { page, pageSize, token } })
+ const { catalog, db, table, snapshotId, page, pageSize, ref, token } = params
+ return
request.get(`api/v1/tables/catalogs/${catalog}/dbs/${db}/tables/${table}/snapshots/${snapshotId}/detail`,
{ params: { page, pageSize, ref, token } })
}
// get operations
export function getOperations(
diff --git a/amoro-web/src/views/tables/components/Snapshots.vue
b/amoro-web/src/views/tables/components/Snapshots.vue
index 219092439..fef7e5768 100644
--- a/amoro-web/src/views/tables/components/Snapshots.vue
+++ b/amoro-web/src/views/tables/components/Snapshots.vue
@@ -157,6 +157,7 @@ async function getBreadcrumbTable() {
const params = {
...sourceData,
snapshotId: snapshotId.value,
+ ref: tblRef.value,
page: breadcrumbPagination.current,
pageSize: breadcrumbPagination.pageSize,
}