From dba6a6461eb21b6edc5767efb685da5b868b1b51 Mon Sep 17 00:00:00 2001 From: ajantha-bhat Date: Fri, 5 Jan 2024 14:29:35 +0530 Subject: [PATCH] Address comments --- .../org/apache/iceberg/spark/BaseFileRewriteCoordinator.java | 4 ++-- .../java/org/apache/iceberg/spark/ScanTaskSetManager.java | 4 ++-- .../src/main/java/org/apache/iceberg/spark/Spark3Util.java | 4 ++-- .../org/apache/iceberg/spark/BaseFileRewriteCoordinator.java | 4 ++-- .../java/org/apache/iceberg/spark/ScanTaskSetManager.java | 4 ++-- .../src/main/java/org/apache/iceberg/spark/Spark3Util.java | 4 ++-- .../org/apache/iceberg/spark/BaseFileRewriteCoordinator.java | 4 ++-- .../java/org/apache/iceberg/spark/ScanTaskSetManager.java | 4 ++-- .../src/main/java/org/apache/iceberg/spark/Spark3Util.java | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/BaseFileRewriteCoordinator.java b/spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/BaseFileRewriteCoordinator.java index 6f683df2cdf9..5c95475d3302 100644 --- a/spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/BaseFileRewriteCoordinator.java +++ b/spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/BaseFileRewriteCoordinator.java @@ -70,12 +70,12 @@ public void clearRewrite(Table table, String fileSetId) { public Set fetchSetIds(Table table) { return resultMap.keySet().stream() - .filter(e -> e.first().equals(Spark3Util.tableUUID(table))) + .filter(e -> e.first().equals(Spark3Util.baseTableUUID(table))) .map(Pair::second) .collect(Collectors.toSet()); } private Pair toId(Table table, String setId) { - return Pair.of(Spark3Util.tableUUID(table), setId); + return Pair.of(Spark3Util.baseTableUUID(table), setId); } } diff --git a/spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/ScanTaskSetManager.java b/spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/ScanTaskSetManager.java index b89be92c3a6b..cab40d103171 100644 --- a/spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/ScanTaskSetManager.java +++ b/spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/ScanTaskSetManager.java @@ -62,12 +62,12 @@ public List removeTasks(Table table, String setId) { public Set fetchSetIds(Table table) { return tasksMap.keySet().stream() - .filter(e -> e.first().equals(Spark3Util.tableUUID(table))) + .filter(e -> e.first().equals(Spark3Util.baseTableUUID(table))) .map(Pair::second) .collect(Collectors.toSet()); } private Pair toId(Table table, String setId) { - return Pair.of(Spark3Util.tableUUID(table), setId); + return Pair.of(Spark3Util.baseTableUUID(table), setId); } } diff --git a/spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java b/spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java index 48d22fc8961c..10b856a7acf0 100644 --- a/spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java +++ b/spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java @@ -947,14 +947,14 @@ public static org.apache.spark.sql.catalyst.TableIdentifier toV1TableIdentifier( return org.apache.spark.sql.catalyst.TableIdentifier.apply(table, database); } - static String tableUUID(org.apache.iceberg.Table table) { + static String baseTableUUID(org.apache.iceberg.Table table) { if (table instanceof HasTableOperations) { TableOperations ops = ((HasTableOperations) table).operations(); return ops.current().uuid(); } else if (table instanceof BaseMetadataTable) { return ((BaseMetadataTable) table).table().operations().current().uuid(); } else { - return null; + throw new UnsupportedOperationException("Cannot retrieve UUID for table " + table.name()); } } diff --git a/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/BaseFileRewriteCoordinator.java b/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/BaseFileRewriteCoordinator.java index 6f683df2cdf9..5c95475d3302 100644 --- a/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/BaseFileRewriteCoordinator.java +++ b/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/BaseFileRewriteCoordinator.java @@ -70,12 +70,12 @@ public void clearRewrite(Table table, String fileSetId) { public Set fetchSetIds(Table table) { return resultMap.keySet().stream() - .filter(e -> e.first().equals(Spark3Util.tableUUID(table))) + .filter(e -> e.first().equals(Spark3Util.baseTableUUID(table))) .map(Pair::second) .collect(Collectors.toSet()); } private Pair toId(Table table, String setId) { - return Pair.of(Spark3Util.tableUUID(table), setId); + return Pair.of(Spark3Util.baseTableUUID(table), setId); } } diff --git a/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/ScanTaskSetManager.java b/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/ScanTaskSetManager.java index b89be92c3a6b..cab40d103171 100644 --- a/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/ScanTaskSetManager.java +++ b/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/ScanTaskSetManager.java @@ -62,12 +62,12 @@ public List removeTasks(Table table, String setId) { public Set fetchSetIds(Table table) { return tasksMap.keySet().stream() - .filter(e -> e.first().equals(Spark3Util.tableUUID(table))) + .filter(e -> e.first().equals(Spark3Util.baseTableUUID(table))) .map(Pair::second) .collect(Collectors.toSet()); } private Pair toId(Table table, String setId) { - return Pair.of(Spark3Util.tableUUID(table), setId); + return Pair.of(Spark3Util.baseTableUUID(table), setId); } } diff --git a/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java b/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java index c512e5781c7f..a81877c98b3d 100644 --- a/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java +++ b/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java @@ -950,14 +950,14 @@ public static org.apache.spark.sql.catalyst.TableIdentifier toV1TableIdentifier( return org.apache.spark.sql.catalyst.TableIdentifier.apply(table, database); } - static String tableUUID(org.apache.iceberg.Table table) { + static String baseTableUUID(org.apache.iceberg.Table table) { if (table instanceof HasTableOperations) { TableOperations ops = ((HasTableOperations) table).operations(); return ops.current().uuid(); } else if (table instanceof BaseMetadataTable) { return ((BaseMetadataTable) table).table().operations().current().uuid(); } else { - return null; + throw new UnsupportedOperationException("Cannot retrieve UUID for table " + table.name()); } } diff --git a/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/BaseFileRewriteCoordinator.java b/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/BaseFileRewriteCoordinator.java index 6f683df2cdf9..5c95475d3302 100644 --- a/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/BaseFileRewriteCoordinator.java +++ b/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/BaseFileRewriteCoordinator.java @@ -70,12 +70,12 @@ public void clearRewrite(Table table, String fileSetId) { public Set fetchSetIds(Table table) { return resultMap.keySet().stream() - .filter(e -> e.first().equals(Spark3Util.tableUUID(table))) + .filter(e -> e.first().equals(Spark3Util.baseTableUUID(table))) .map(Pair::second) .collect(Collectors.toSet()); } private Pair toId(Table table, String setId) { - return Pair.of(Spark3Util.tableUUID(table), setId); + return Pair.of(Spark3Util.baseTableUUID(table), setId); } } diff --git a/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/ScanTaskSetManager.java b/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/ScanTaskSetManager.java index b89be92c3a6b..cab40d103171 100644 --- a/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/ScanTaskSetManager.java +++ b/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/ScanTaskSetManager.java @@ -62,12 +62,12 @@ public List removeTasks(Table table, String setId) { public Set fetchSetIds(Table table) { return tasksMap.keySet().stream() - .filter(e -> e.first().equals(Spark3Util.tableUUID(table))) + .filter(e -> e.first().equals(Spark3Util.baseTableUUID(table))) .map(Pair::second) .collect(Collectors.toSet()); } private Pair toId(Table table, String setId) { - return Pair.of(Spark3Util.tableUUID(table), setId); + return Pair.of(Spark3Util.baseTableUUID(table), setId); } } diff --git a/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java b/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java index 62c0bff329b5..39518ffbb945 100644 --- a/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java +++ b/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java @@ -950,14 +950,14 @@ public static org.apache.spark.sql.catalyst.TableIdentifier toV1TableIdentifier( return org.apache.spark.sql.catalyst.TableIdentifier.apply(table, database); } - static String tableUUID(org.apache.iceberg.Table table) { + static String baseTableUUID(org.apache.iceberg.Table table) { if (table instanceof HasTableOperations) { TableOperations ops = ((HasTableOperations) table).operations(); return ops.current().uuid(); } else if (table instanceof BaseMetadataTable) { return ((BaseMetadataTable) table).table().operations().current().uuid(); } else { - return null; + throw new UnsupportedOperationException("Cannot retrieve UUID for table " + table.name()); } }