openinx commented on a change in pull request #1815:
URL: https://github.com/apache/iceberg/pull/1815#discussion_r530234739
##########
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) {
Review comment:
For an unpartitioned table, seems we need to throw a
`TableNotPartitionedException` ? I read the java doc from `listPartitions` in
flink's Catalog interface:
```java
/**
* Get CatalogPartitionSpec of all partitions of the table.
*
* @param tablePath path of the table
* @return a list of CatalogPartitionSpec of the table
*
* @throws TableNotExistException thrown if the table does not exist in
the catalog
* @throws TableNotPartitionedException thrown if the table is not
partitioned
* @throws CatalogException in case of any runtime exception
*/
List<CatalogPartitionSpec> listPartitions(ObjectPath tablePath)
throws TableNotExistException, TableNotPartitionedException,
CatalogException;
```
----------------------------------------------------------------
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]