This is an automated email from the ASF dual-hosted git repository.

xuba 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 deb437021 [AMORO-3622] Fix expiring data when file without upperbounds 
(#3623)
deb437021 is described below

commit deb4370215b17ed1db680e846c8c3876b1586d4c
Author: Xu Bai <[email protected]>
AuthorDate: Tue Jun 17 22:03:01 2025 +0800

    [AMORO-3622] Fix expiring data when file without upperbounds (#3623)
---
 .../maintainer/IcebergTableMaintainer.java         | 42 +++++++++++-----------
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git 
a/amoro-ams/src/main/java/org/apache/amoro/server/optimizing/maintainer/IcebergTableMaintainer.java
 
b/amoro-ams/src/main/java/org/apache/amoro/server/optimizing/maintainer/IcebergTableMaintainer.java
index 3f45e40b1..575b3aa59 100644
--- 
a/amoro-ams/src/main/java/org/apache/amoro/server/optimizing/maintainer/IcebergTableMaintainer.java
+++ 
b/amoro-ams/src/main/java/org/apache/amoro/server/optimizing/maintainer/IcebergTableMaintainer.java
@@ -73,6 +73,7 @@ import org.slf4j.LoggerFactory;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.ByteBuffer;
 import java.time.Instant;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
@@ -977,28 +978,29 @@ public class IcebergTableMaintainer implements 
TableMaintainer {
       String numberDateFormatter,
       Comparable<?> expireValue) {
     Type type = field.type();
-    Object upperBound =
-        Conversions.fromByteBuffer(type, 
contentFile.upperBounds().get(field.fieldId()));
     Literal<Long> literal = Literal.of(Long.MAX_VALUE);
-    if (null == upperBound) {
-      if (canBeExpireByPartitionValue(contentFile, field, expireValue)) {
-        literal = Literal.of(0L);
-      }
-    } else if (upperBound instanceof Long) {
-      switch (type.typeId()) {
-        case TIMESTAMP:
-          // nanosecond -> millisecond
-          literal = Literal.of((Long) upperBound / 1000);
-          break;
-        default:
-          if (numberDateFormatter.equals(EXPIRE_TIMESTAMP_MS)) {
-            literal = Literal.of((Long) upperBound);
-          } else if (numberDateFormatter.equals(EXPIRE_TIMESTAMP_S)) {
-            // second -> millisecond
-            literal = Literal.of((Long) upperBound * 1000);
-          }
+
+    Map<Integer, ByteBuffer> upperBounds = contentFile.upperBounds();
+    if (upperBounds == null || !upperBounds.containsKey(field.fieldId())) {
+      return canBeExpireByPartitionValue(contentFile, field, expireValue)
+          ? Literal.of(0L)
+          : literal;
+    }
+
+    Object upperBound = Conversions.fromByteBuffer(type, 
upperBounds.get(field.fieldId()));
+    if (upperBound instanceof Long) {
+      if (type.typeId() == Type.TypeID.TIMESTAMP) {
+        // nanosecond -> millisecond
+        literal = Literal.of((Long) upperBound / 1000);
+      } else {
+        if (numberDateFormatter.equals(EXPIRE_TIMESTAMP_MS)) {
+          literal = Literal.of((Long) upperBound);
+        } else if (numberDateFormatter.equals(EXPIRE_TIMESTAMP_S)) {
+          // second -> millisecond
+          literal = Literal.of((Long) upperBound * 1000);
+        }
       }
-    } else if (type.typeId().equals(Type.TypeID.STRING)) {
+    } else if (type.typeId() == Type.TypeID.STRING) {
       literal =
           Literal.of(
               LocalDate.parse(upperBound.toString(), formatter)

Reply via email to