openinx commented on a change in pull request #1815:
URL: https://github.com/apache/iceberg/pull/1815#discussion_r530235128



##########
File path: flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java
##########
@@ -619,7 +624,25 @@ public void alterPartitionColumnStatistics(ObjectPath 
tablePath, CatalogPartitio
   @Override
   public List<CatalogPartitionSpec> listPartitions(ObjectPath tablePath)
       throws CatalogException {
-    throw new UnsupportedOperationException();
+    Table table = icebergCatalog.loadTable(toIdentifier(tablePath));
+    Set<CatalogPartitionSpec> set = Sets.newHashSet();
+    try (CloseableIterable<FileScanTask> tasks = table.newScan().planFiles()) {
+      for (DataFile dataFile : CloseableIterable.transform(tasks, 
FileScanTask::file)) {
+        Map<String, String> map = Maps.newHashMap();
+        StructLike structLike = dataFile.partition();
+        PartitionSpec spec = table.specs().get(dataFile.specId());
+        for (int i = 0; i < structLike.size(); i++) {
+          map.put(spec.fields().get(i).name(), 
String.valueOf(structLike.get(i, Object.class)));
+        }
+        // if the table is unpartitioned table, do not add it to set
+        if (map.size() > 0) {
+          set.add(new CatalogPartitionSpec(map));
+        }
+      }
+    } catch (IOException e) {
+      throw new UncheckedIOException(e);

Review comment:
       `@throws CatalogException        in case of any runtime exception`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to