Skip to content

Commit

Permalink
[AMORO-2208] Validate NULL data expiration configuration (#2209)
Browse files Browse the repository at this point in the history
  • Loading branch information
XBaith authored Oct 31, 2023
1 parent 2622dc4 commit 8d50d9c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.netease.arctic.utils.CompatiblePropertyUtil;

import java.util.Map;
import java.util.Optional;

@JsonIgnoreProperties(ignoreUnknown = true)
public class TableConfiguration {
Expand Down Expand Up @@ -86,7 +87,7 @@ public TableConfiguration setDeleteDanglingDeleteFilesEnabled(
}

public DataExpirationConfig getExpiringDataConfig() {
return expiringDataConfig;
return Optional.ofNullable(expiringDataConfig).orElse(new DataExpirationConfig());
}

public TableConfiguration setExpiringDataConfig(DataExpirationConfig expiringDataConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ private static CloseableIterable<IcebergFileEntry> fileScan(
TableScan tableScan = table.newScan().filter(partitionFilter).includeColumnStats();

CloseableIterable<FileScanTask> tasks;
long snapshotId =
null == snapshot ? ArcticServiceConstants.INVALID_SNAPSHOT_ID : snapshot.snapshotId();
long snapshotId = getSnapshotId(snapshot);
if (snapshotId == ArcticServiceConstants.INVALID_SNAPSHOT_ID) {
tasks = tableScan.planFiles();
} else {
Expand Down Expand Up @@ -257,8 +256,8 @@ private static void purgeTableData(
} catch (IOException e) {
throw new RuntimeException(e);
}
expireFiles(changeTable, changeSnapshot.snapshotId(), changeExpiredFiles, expireTimestamp);
expireFiles(baseTable, baseSnapshot.snapshotId(), baseExpiredFiles, expireTimestamp);
expireFiles(changeTable, getSnapshotId(changeSnapshot), changeExpiredFiles, expireTimestamp);
expireFiles(baseTable, getSnapshotId(baseSnapshot), baseExpiredFiles, expireTimestamp);
} else {
UnkeyedTable unkeyedTable = table.asUnkeyedTable();
Snapshot snapshot = unkeyedTable.currentSnapshot();
Expand All @@ -279,7 +278,7 @@ private static void purgeTableData(
} catch (IOException e) {
throw new RuntimeException(e);
}
expireFiles(unkeyedTable, snapshot.snapshotId(), expiredFiles, expireTimestamp);
expireFiles(unkeyedTable, getSnapshotId(snapshot), expiredFiles, expireTimestamp);
}
}

Expand Down Expand Up @@ -525,6 +524,10 @@ private static Literal<Long> getExpireTimestampLiteral(
return literal;
}

private static long getSnapshotId(Snapshot snapshot) {
return null == snapshot ? ArcticServiceConstants.INVALID_SNAPSHOT_ID : snapshot.snapshotId();
}

protected static class FileEntry extends IcebergFileEntry {

private final boolean isChange;
Expand Down

0 comments on commit 8d50d9c

Please sign in to comment.