rdblue commented on code in PR #19129:
URL: https://github.com/apache/iceberg/pull/19129#discussion_r4807287672
##########
core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java:
##########
@@ -191,70 +186,65 @@ protected void failMissingDeletePaths() {
* @param expr an expression to match rows.
*/
protected void deleteByRowFilter(Expression expr) {
+ producer.deleteByRowFilter(expr);
this.deleteExpression = expr;
- filterManager.deleteByRowFilter(expr);
- // if a delete file matches the row filter, then it can be deleted because
the rows will also be
- // deleted
- deleteFilterManager.deleteByRowFilter(expr);
+ this.deletesDataFiles = true;
}
/** Add a partition tuple to drop from the table during the delete phase. */
protected void dropPartition(int specId, StructLike partition) {
- // dropping the data in a partition also drops all deletes in the partition
- filterManager.dropPartition(specId, partition);
- deleteFilterManager.dropPartition(specId, partition);
+ producer.deletePartition(specId, partition);
+ this.deletesDataFiles = true;
}
/** Add a specific data file to be deleted in the new snapshot. */
protected void delete(DataFile file) {
- filterManager.delete(file);
+ producer.deleteDataFile(file);
+ this.deletesDataFiles = true;
}
/** Add a specific delete file to be deleted in the new snapshot. */
protected void delete(DeleteFile file) {
- deleteFilterManager.delete(file);
+ producer.deleteDeleteFile(file);
+ this.deletesDeleteFiles = true;
}
/** Add a specific data path to be deleted in the new snapshot. */
protected void delete(CharSequence path) {
// this is an old call that never worked for delete files and can only be
used to remove data
// files.
- filterManager.delete(path);
+ producer.deleteDataFile(path);
}
protected boolean deletesDataFiles() {
- return filterManager.containsDeletes();
+ return deletesDataFiles;
}
protected boolean deletesDeleteFiles() {
- return deleteFilterManager.containsDeletes();
+ return deletesDeleteFiles;
}
protected boolean addsDataFiles() {
- return !newDataFilesBySpec.isEmpty();
+ return !appendedDataFiles.isEmpty();
}
protected boolean addsDeleteFiles() {
- return !v2Deletes.isEmpty()
- || dvsByReferencedFile.values().stream().anyMatch(dvs ->
!dvs.isEmpty());
+ return !addedDeleteFiles.isEmpty();
}
/** Add a data file to the new snapshot. */
protected void add(DataFile file) {
Preconditions.checkNotNull(file, "Invalid data file: null");
- PartitionSpec spec = spec(file.specId());
- Preconditions.checkArgument(
- spec != null,
- "Cannot find partition spec %s for data file: %s",
- file.specId(),
- file.location());
-
- DataFileSet dataFiles =
- newDataFilesBySpec.computeIfAbsent(spec.specId(), ignored ->
DataFileSet.create());
- if (dataFiles.add(Delegates.suppressFirstRowId(file))) {
- addedDataFilesSummary.addedFile(spec, file);
- hasNewDataFiles = true;
- }
+ producer.appendDataFile(file);
+ appendedDataFiles.add(file);
+ addedDataFilesSummary.addedFile(spec(file.specId()), file);
Review Comment:
> should a data file that is added twice still be counted once?
At some point, the behavior of MergingSnapshotProducer was updated to
deduplicate files. I think that's incorrect and duplicate files should be
rejected instead of allowing commits to succeed with obvious bugs.
For stats, I think that the stats should reflect whatever is actually
committed to the table. That's why I updated this to get the files actually
committed and base stats on that in an update:
```java
List<DataFile> addedDataFiles = manifestListProducer.addedDataFiles();
...
addedDataFiles.forEach(file ->
summaryBuilder.addedFile(spec(file.specId()), file));
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]