rdblue commented on a change in pull request #351: Extend Iceberg with a way to 
overwrite files for eager updates/deletes
URL: https://github.com/apache/incubator-iceberg/pull/351#discussion_r315463525
 
 

 ##########
 File path: core/src/main/java/org/apache/iceberg/OverwriteData.java
 ##########
 @@ -88,6 +119,42 @@ public OverwriteFiles validateAddedFiles() {
       }
     }
 
+    if (conflictDetectionFilter != null) {
+      PartitionSpec spec = writeSpec();
+      Expression inclusiveExpr = 
Projections.inclusive(spec).project(conflictDetectionFilter);
+      Evaluator inclusive = new Evaluator(spec.partitionType(), inclusiveExpr);
+
+      InclusiveMetricsEvaluator metrics = new 
InclusiveMetricsEvaluator(base.schema(), conflictDetectionFilter);
+
+      List<DataFile> newFiles = collectNewFiles(base);
+      for (DataFile newFile : newFiles) {
+        ValidationException.check(
+            !inclusive.eval(newFile.partition()) || !metrics.eval(newFile),
+            "A conflicting file was appended that matches filter '%s': %s",
 
 Review comment:
   Minor: This isn't quite correct. This doesn't guarantee that a file matches 
the filter, just that it may contain data that matches the filter. For example, 
if a table is bucketed by `id` and a file has ids `x` and `z` where `x < y` and 
`y < z` and `x`, `y`, and `z` all hash to the same bucket, then `id = y` would 
match the file even though `y` isn't actually in it.

----------------------------------------------------------------
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]


With regards,
Apache Git Services

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

Reply via email to