Skip to content

Commit

Permalink
[GOBBLIN-2169] avoid npe while overwrite if table has no previous sna…
Browse files Browse the repository at this point in the history
…pshot (#4071)
  • Loading branch information
Blazer-007 authored and Will-Lo committed Oct 31, 2024
1 parent 7aede43 commit 7a09610
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ protected void registerIcebergTable(TableMetadata srcMetadata, TableMetadata dst
*
* @param icebergPartitionFilterPredicate the predicate to filter partitions
* @return a list of data files that match the partition filter predicate
* @throws TableNotFoundException if error occurred while accessing the table metadata
* @throws RuntimeException if error occurred while reading the manifest file
* @throws IOException if error occurred while accessing the table metadata or reading the manifest file
*/
public List<DataFile> getPartitionSpecificDataFiles(Predicate<StructLike> icebergPartitionFilterPredicate)
throws IOException {
Expand Down Expand Up @@ -286,7 +285,13 @@ protected void overwritePartition(List<DataFile> dataFiles, String partitionColN
if (dataFiles.isEmpty()) {
return;
}
log.info("~{}~ SnapshotId before overwrite: {}", tableId, accessTableMetadata().currentSnapshot().snapshotId());
TableMetadata tableMetadata = accessTableMetadata();
Optional<Snapshot> currentSnapshot = Optional.ofNullable(tableMetadata.currentSnapshot());
if (currentSnapshot.isPresent()) {
log.info("~{}~ SnapshotId before overwrite: {}", tableId, currentSnapshot.get().snapshotId());
} else {
log.warn("~{}~ No current snapshot found before overwrite", tableId);
}
OverwriteFiles overwriteFiles = this.table.newOverwrite();
overwriteFiles.overwriteByRowFilter(Expressions.equal(partitionColName, partitionValue));
dataFiles.forEach(overwriteFiles::addFile);
Expand Down

0 comments on commit 7a09610

Please sign in to comment.