Skip to content

Commit fda105e

Browse files
authored
[Hotfix] Fix incorrect Last Commit Time showing year 58000+ in partition view (#4083)
The last_updated_at column from Iceberg PARTITIONS metadata table stores timestamps in microseconds, but it was passed directly to the frontend which expects milliseconds. This caused the displayed year to be ~58000. Convert microseconds to milliseconds by dividing by 1000, consistent with how snapshot.timestampMillis() is used elsewhere. Signed-off-by: Jiwon Park <[email protected]>
1 parent e3671b5 commit fda105e

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

amoro-ams/src/main/java/org/apache/amoro/server/dashboard/MixedAndIcebergTableDescriptor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,9 @@ private List<PartitionBaseInfo> collectPartitionsFromTable(Table table) {
553553
// This will be updated once Iceberg supports reporting delete file sizes.
554554
// See: https://github.com/apache/iceberg/issues/14803
555555
partitionInfo.setFileSize(totalDataFileSize != null ? totalDataFileSize : 0L);
556-
partitionInfo.setLastCommitTime(lastUpdatedAt != null ? lastUpdatedAt : 0L);
556+
// last_updated_at from Iceberg PARTITIONS metadata table is in microseconds,
557+
// convert to milliseconds for consistency with snapshot.timestampMillis()
558+
partitionInfo.setLastCommitTime(lastUpdatedAt != null ? lastUpdatedAt / 1000 : 0L);
557559

558560
partitions.add(partitionInfo);
559561
}

amoro-ams/src/test/java/org/apache/amoro/server/dashboard/TestIcebergServerTableDescriptor.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,20 @@ public void testGetTablePartitions() {
107107
Assert.assertEquals("Should have 1 file total", 1, totalFiles);
108108

109109
// Verify we used PARTITIONS metadata table which provides fileSize and lastCommitTime
110+
// Year 2100 in milliseconds - any reasonable timestamp must be below this
111+
long year2100InMillis = 4102444800000L;
110112
for (org.apache.amoro.table.descriptor.PartitionBaseInfo partition : partitions) {
111113
// File size should be available from PARTITIONS metadata table
112114
Assert.assertTrue(
113115
"FileSize should be available from PARTITIONS metadata table",
114116
partition.getFileSize() >= 0);
115-
// Last commit time should be available from PARTITIONS metadata table
117+
// Last commit time should be available and in milliseconds (not microseconds)
118+
Assert.assertTrue("LastCommitTime should be positive", partition.getLastCommitTime() > 0);
116119
Assert.assertTrue(
117-
"LastCommitTime should be available from PARTITIONS metadata table",
118-
partition.getLastCommitTime() >= 0);
120+
"LastCommitTime should be in milliseconds, not microseconds (got "
121+
+ partition.getLastCommitTime()
122+
+ ")",
123+
partition.getLastCommitTime() < year2100InMillis);
119124
}
120125
}
121126

0 commit comments

Comments
 (0)