RussellSpitzer commented on a change in pull request #2210:
URL: https://github.com/apache/iceberg/pull/2210#discussion_r591645035
##########
File path: spark/src/main/java/org/apache/iceberg/spark/SparkTableUtil.java
##########
@@ -621,6 +640,32 @@ public static void importSparkPartitions(
}
}
+ public static List<SparkPartition> filterPartitions(List<SparkPartition>
partitions,
+ Map<String, String>
partitionFilter) {
+ if (partitionFilter.isEmpty()) {
+ // No partition filter arg
+
+ if (partitions.isEmpty()) {
+ throw new IllegalArgumentException("Cannot add files, no files found
in the table.");
+ }
+ return partitions;
+ } else {
+ // Partition filter arg passed
+
+ List<SparkTableUtil.SparkPartition> filteredPartitions = partitions
+ .stream().filter(p ->
p.getValues().entrySet().containsAll(partitionFilter.entrySet()))
+ .collect(Collectors.toList());
+
+ Preconditions.checkArgument(!filteredPartitions.isEmpty(),
Review comment:
I can move them both to the import, I do think it should be an exception
because I dislike silent noops
----------------------------------------------------------------
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]