wgtmac commented on code in PR #427:
URL: https://github.com/apache/iceberg-cpp/pull/427#discussion_r2638405396
##########
src/iceberg/transaction.cc:
##########
@@ -98,7 +102,14 @@ Result<std::shared_ptr<Table>> Transaction::Commit() {
}
// XXX: we should handle commit failure and retry here.
- return table_->catalog()->UpdateTable(table_->name(), requirements, updates);
+ ICEBERG_ASSIGN_OR_RAISE(auto updated_table, table_->catalog()->UpdateTable(
+ table_->name(),
requirements, updates));
+
+ // Mark as committed and update table reference
+ committed_ = true;
+ table_ = updated_table;
Review Comment:
```suggestion
table_ = std::move(updated_table);
```
##########
src/iceberg/transaction.cc:
##########
@@ -98,7 +102,14 @@ Result<std::shared_ptr<Table>> Transaction::Commit() {
}
// XXX: we should handle commit failure and retry here.
- return table_->catalog()->UpdateTable(table_->name(), requirements, updates);
+ ICEBERG_ASSIGN_OR_RAISE(auto updated_table, table_->catalog()->UpdateTable(
+ table_->name(),
requirements, updates));
+
+ // Mark as committed and update table reference
+ committed_ = true;
+ table_ = updated_table;
+
+ return updated_table;
Review Comment:
```suggestion
return table_;
```
##########
src/iceberg/transaction.cc:
##########
@@ -75,13 +75,17 @@ Status
Transaction::Apply(std::vector<std::unique_ptr<TableUpdate>> updates) {
}
Result<std::shared_ptr<Table>> Transaction::Commit() {
+ if (committed_) {
+ return InvalidArgument("Transaction already committed");
Review Comment:
```suggestion
return Invalid("Transaction already committed");
```
This is no argument so we can simply use `Invalid`.
--
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]