Skip to content

Commit

Permalink
[Bug] Fix the NPE when report the statistic with DeletionFile (#4485)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aitozi authored Nov 8, 2024
1 parent 420fc7d commit 2eca3a7
Showing 1 changed file with 1 addition and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.apache.paimon.metastore.MetastoreClient;
import org.apache.paimon.table.FileStoreTable;
import org.apache.paimon.table.source.DataSplit;
import org.apache.paimon.table.source.DeletionFile;
import org.apache.paimon.table.source.ScanMode;
import org.apache.paimon.table.source.snapshot.SnapshotReader;
import org.apache.paimon.utils.Preconditions;
Expand Down Expand Up @@ -86,22 +85,14 @@ public void report(String partition, long modifyTime) throws Exception {
for (DataFileMeta fileMeta : fileMetas) {
totalSize += fileMeta.fileSize();
}

if (split.deletionFiles().isPresent()) {
fileCount += split.deletionFiles().get().size();
totalSize +=
split.deletionFiles().get().stream()
.map(DeletionFile::length)
.reduce(0L, Long::sum);
}
}
Map<String, String> statistic = new HashMap<>();
statistic.put(NUM_FILES_PROP, String.valueOf(fileCount));
statistic.put(TOTAL_SIZE_PROP, String.valueOf(totalSize));
statistic.put(NUM_ROWS_PROP, String.valueOf(rowCount));
statistic.put(HIVE_LAST_UPDATE_TIME_PROP, String.valueOf(modifyTime / 1000));

LOG.info("alter partition {} with statistic {}.", partition, statistic);
LOG.info("alter partition {} with statistic {}.", partitionSpec, statistic);
metastoreClient.alterPartition(partitionSpec, statistic, modifyTime);
}
}
Expand Down

0 comments on commit 2eca3a7

Please sign in to comment.