public static void createTag(Table table, AlterTableSnapshotRefSpec.CreateSnapshotRefSpec createTagSpec) {
    String tagName = createTagSpec.getRefName();
    boolean refExistsAsTag = refExistsAsTag(table, tagName);
    if (createTagSpec.isIfNotExists() && refExistsAsTag) {
      return;
    }
    boolean isReplace = createTagSpec.isReplace() && refExistsAsTag;
    Long snapshotId = null;
    if (createTagSpec.getSnapshotId() != null) {
      snapshotId = createTagSpec.getSnapshotId();
    } else if (createTagSpec.getAsOfTime() != null) {
      snapshotId = SnapshotUtil.snapshotIdAsOfTime(table, createTagSpec.getAsOfTime());
    } else {
      snapshotId = table.currentSnapshot().snapshotId();
    }
    ManageSnapshots manageSnapshots = table.manageSnapshots();
    if (isReplace) {
      LOG.info("Replacing tag {} on iceberg table {} with snapshotId {}", tagName, table.name(), snapshotId);
      manageSnapshots.replaceTag(tagName, snapshotId);
    } else {
      LOG.info("Creating tag {} on iceberg table {} with snapshotId {}", tagName, table.name(), snapshotId);
      manageSnapshots.createTag(tagName, snapshotId);
    }
    if (createTagSpec.getMaxRefAgeMs() != null) {
      manageSnapshots.setMaxRefAgeMs(tagName, createTagSpec.getMaxRefAgeMs());
    }

    manageSnapshots.commit();
  }
Create a branch on the iceberg table
@param table the iceberg table
@param createBranchSpec Get the basic parameters needed to create a branch
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/IcebergSnapshotRefExec.java