Skip to content

Commit

Permalink
[AMORO-2988] Add more base info for the table detail page (#2989)
Browse files Browse the repository at this point in the history
* [AMORO-2988] Add more base info for the table detail page

* code refactor

* code refactor

* code refactor

* code refactor

* remove some code
  • Loading branch information
tcodehuber authored Jul 5, 2024
1 parent 89dfe86 commit 329d920
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,10 @@ const changeMetricsMap: IMap<string | number> = {
const state = reactive({
detailLoading: false,
baseDetailInfo: {
optimizingStatus: '',
tableType: '',
tableName: '',
createTime: '',
size: '',
file: '',
averageFile: '',
tableFormat: '',
hasPartition: false, // Whether there is a partition, if there is no partition, the file list will be displayed
} as IBaseDetailInfo,
Expand All @@ -93,7 +91,7 @@ async function getTableDetails() {
state.baseDetailInfo = {
...tableSummary,
tableType,
tableName: tableIdentifier?.tableName || '',
tableName: `${tableIdentifier?.catalog || ''}.${tableIdentifier?.database || ''}.${tableIdentifier?.tableName || ''}`,
createTime: createTime ? dateFormat(createTime) : '',
hasPartition: !!(partitionColumnList?.length),
}
Expand Down
17 changes: 8 additions & 9 deletions amoro-ams/amoro-ams-dashboard/src/views/tables/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@ export default defineComponent({
activeKey: 'Details',
isSecondaryNav: false,
baseInfo: {
optimizingStatus: '',
tableType: '',
tableName: '',
createTime: '',
size: '',
file: '',
averageFile: '',
tableFormat: '',
hasPartition: false,
} as IBaseDetailInfo,
Expand Down Expand Up @@ -141,15 +139,16 @@ export default defineComponent({
<div class="g-flex-col">
<div class="g-flex">
<span :title="baseInfo.tableName" class="table-name g-text-nowrap">{{ baseInfo.tableName }}</span>
<span v-if="!isIceberg" class="create-time">{{ `${$t('createTime')}: ${baseInfo.createTime}` }}</span>
</div>
<div class="table-info g-flex-ac">
<p>{{ `${$t('table')}${$t('size')}` }}: <span class="text-color">{{ baseInfo.size }}</span></p>
<p>{{ $t('optimizingStatus') }}: <span class="text-color">{{ baseInfo.optimizingStatus }}</span></p>
<a-divider type="vertical" />
<p>{{ $t('file') }}: <span class="text-color">{{ baseInfo.file }}</span></p>
<a-divider type="vertical" />
<p>{{ $t('averageFileSize') }}: <span class="text-color">{{ baseInfo.averageFile }}</span></p>
<p>{{ $t('records') }}: <span class="text-color">{{ baseInfo.records }}</span></p>
<a-divider type="vertical" />
<template v-if="!isIceberg">
<p>{{ $t('createTime') }}: <span class="text-color">{{ baseInfo.createTime }}</span></p>
<a-divider type="vertical" />
</template>
<p>{{ $t('tableFormat') }}: <span class="text-color">{{ baseInfo.tableFormat }}</span></p>
</div>
</div>
Expand Down Expand Up @@ -194,7 +193,7 @@ export default defineComponent({
font-size: 24px;
line-height: 1.5;
margin-right: 16px;
max-width: 400px;
max-width: 600px;
padding-left: 24px;
}
.table-info {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ public ServerTableMeta getTableDetail(AmoroTable<?> amoroTable) {
tableSummary.put("file", tableFileCnt);
tableSummary.put(
"averageFile", AmsUtil.byteToXB(tableFileCnt == 0 ? 0 : tableSize / tableFileCnt));

tableSummary.put("records", getRecordsOfTable(table));
tableSummary.put("tableFormat", tableFormat);
serverTableMeta.setTableSummary(tableSummary);
return serverTableMeta;
Expand All @@ -173,6 +175,28 @@ private String decorateTableFormat(AmoroTable table) {
return sb.toString();
}

private long getRecordsOfTable(MixedTable mixedTable) {
long totalRecords;
if (mixedTable.isKeyedTable()) {
Snapshot changeSnapshot =
SnapshotUtil.latestSnapshot(mixedTable.asKeyedTable().changeTable(), null);
Snapshot baseSnapshot =
SnapshotUtil.latestSnapshot(mixedTable.asKeyedTable().baseTable(), null);
totalRecords =
PropertyUtil.propertyAsLong(
changeSnapshot.summary(), SnapshotSummary.TOTAL_RECORDS_PROP, 0L)
+ PropertyUtil.propertyAsLong(
baseSnapshot.summary(), SnapshotSummary.TOTAL_RECORDS_PROP, 0L);
} else {
totalRecords =
PropertyUtil.propertyAsLong(
SnapshotUtil.latestSnapshot(mixedTable.asUnkeyedTable(), null).summary(),
SnapshotSummary.TOTAL_RECORDS_PROP,
0L);
}
return totalRecords;
}

private Long snapshotIdOfTableRef(Table table, String ref) {
if (ref == null) {
ref = SnapshotRef.MAIN_BRANCH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public ServerTableMeta getTableDetail(AmoroTable<?> amoroTable) {
tableSummary.put("averageFile", averageFileSize);
tableSummary.put("file", fileCount);
tableSummary.put("size", totalSize);
tableSummary.put("records", snapshotsOfTable.getRecords());

baseMetric.put("totalSize", totalSize);
baseMetric.put("fileCount", fileCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ public void getTableDetail(Context ctx) {
ServerTableMeta serverTableMeta =
tableDescriptor.getTableDetail(
TableIdentifier.of(catalog, database, tableName).buildTableIdentifier());
ServerTableIdentifier serverTableIdentifier =
tableService.getServerTableIdentifier(
TableIdentifier.of(catalog, database, tableName).buildTableIdentifier());
Map<String, Object> tableSummary = serverTableMeta.getTableSummary();
tableSummary.put(
"optimizingStatus", tableService.getRuntime(serverTableIdentifier).getOptimizingStatus());

ctx.json(OkResponse.of(serverTableMeta));
}
Expand Down

0 comments on commit 329d920

Please sign in to comment.