rdblue commented on a change in pull request #2293:
URL: https://github.com/apache/iceberg/pull/2293#discussion_r600001818
##########
File path: core/src/main/java/org/apache/iceberg/BaseRewriteFiles.java
##########
@@ -57,4 +64,11 @@ public RewriteFiles rewriteFiles(Set<DataFile>
filesToDelete, Set<DataFile> file
return this;
}
+
+ @Override
+ public RewriteFiles rewriteSpec(PartitionSpec newSpec) {
+
Preconditions.checkArgument(current().specsById().containsKey(newSpec.specId()),
+ "Invalid spec with id %d", newSpec.specId());
+ return new BaseRewriteFiles(tableName(), ops(), newSpec);
Review comment:
Not returning `this` breaks method chaining because you can't do this:
```java
RewriteFiles rewrite = table.newRewriteFiles();
if (!spec.equals(table.spec())) {
rewrite.rewriteSpec(spec);
}
rewrite.commit();
```
I think as a result, we would need to support changing the spec in the
underlying class, `MergingSnapshotProducer`. There are a couple of ways to do
that. One is to validate that there is only one output spec like you do above.
Another is to support writing with multiple specs. By not adding a
`rewriteSpec` method and instead detecting from data files, we can keep
flexibility and enforce the single spec for now and relax that constraint later.
--
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]