rdblue commented on code in PR #13631:
URL: https://github.com/apache/iceberg/pull/13631#discussion_r2240560400
##########
core/src/main/java/org/apache/iceberg/BaseTransaction.java:
##########
@@ -121,180 +121,148 @@ public TableOperations underlyingOps() {
return ops;
}
- private void checkLastOperationCommitted(String operation) {
+ protected <T extends PendingUpdate> T appendUpdates(T update) {
+ checkLastOperationCommitted(update.getClass().getSimpleName());
+
+ if (update instanceof SnapshotUpdate) {
+ ((SnapshotUpdate) update).deleteWith(enqueueDelete);
+ }
+
+ if (update instanceof SnapshotProducer) {
+ ((SnapshotProducer) update).reportWith(reporter);
+ }
+
+ this.updates.add(update);
+ return update;
+ }
+
+ protected void checkLastOperationCommitted(String operation) {
Preconditions.checkState(
hasLastOpCommitted, "Cannot create new %s: last operation has not
committed", operation);
- this.hasLastOpCommitted = false;
+
+ // SnapshotManager handles its own commits internally
+ if (!SnapshotManager.class.getSimpleName().equals(operation)) {
+ this.hasLastOpCommitted = false;
+ }
}
@Override
public UpdateSchema updateSchema() {
- checkLastOperationCommitted("UpdateSchema");
UpdateSchema schemaChange = new SchemaUpdate(transactionOps);
- updates.add(schemaChange);
- return schemaChange;
+ return appendUpdates(schemaChange);
Review Comment:
Why assign the updates to variables? It is now used just once so you could
change these to a simpler form:
```java
return appendUpdate(new SchemaUpdate(transactionOps));
```
--
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]