mxm commented on code in PR #18356:
URL: https://github.com/apache/iceberg/pull/18356#discussion_r4193742462
##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/TableUpdater.java:
##########
@@ -104,23 +105,37 @@ private void findOrCreateBranch(TableIdentifier
identifier, String branch) {
String fromCache = cache.branch(identifier, branch);
if (fromCache == null) {
Table table = catalog.loadTable(identifier);
- try {
- table.manageSnapshots().createBranch(branch).commit();
- LOG.info("Branch {} for {} created", branch, identifier);
- } catch (CommitFailedException e) {
- table.refresh();
- if (table.refs().containsKey(branch)) {
- LOG.debug("Branch {} concurrently created for {}.", branch,
identifier);
- } else {
- LOG.error("Failed to create branch {} for {}.", branch, identifier,
e);
- throw e;
- }
- }
-
+ maybeCreateBranch(identifier, table, branch);
cache.update(identifier, table);
}
}
+ private static void maybeCreateBranch(TableIdentifier identifier, Table
table, String branch) {
Review Comment:
I'm ok with having a separate method here, but I would call it just
`createBranch`. The early return is just an optimization and doesn't have to
leak into the method name.
+1 for removing Mockito in the tests.
--
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]