aokolnychyi commented on a change in pull request #2210:
URL: https://github.com/apache/iceberg/pull/2210#discussion_r591002149
##########
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:
Well, this one is a bit different. So we could probably validate it
here. Do we need to actually fail this with an exception? Or should this be
noop if no partitions match our filter?
----------------------------------------------------------------
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]