This is an automated email from the ASF dual-hosted git repository.
wlo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/gobblin.git
The following commit(s) were added to refs/heads/master by this push:
new edaf474acc [GOBBLIN-2169] avoid npe while overwrite if table has no
previous snapshot (#4071)
edaf474acc is described below
commit edaf474accf85539156b95b121b2e49bba75d4b1
Author: Vivek Rai <[email protected]>
AuthorDate: Thu Oct 31 07:31:34 2024 +0530
[GOBBLIN-2169] avoid npe while overwrite if table has no previous snapshot
(#4071)
---
.../gobblin/data/management/copy/iceberg/IcebergTable.java | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git
a/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/iceberg/IcebergTable.java
b/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/iceberg/IcebergTable.java
index 5221007cdc..e3ec46aa1e 100644
---
a/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/iceberg/IcebergTable.java
+++
b/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/iceberg/IcebergTable.java
@@ -234,8 +234,7 @@ public class IcebergTable {
*
* @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 {
@@ -286,7 +285,13 @@ public class IcebergTable {
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);