public static String fullTableName(String catalogName, TableIdentifier identifier) {
    StringBuilder sb = new StringBuilder();

    if (catalogName.contains("/") || catalogName.contains(":")) {
      // use / for URI-like names: thrift://host:port/db.table
      sb.append(catalogName);
      if (!catalogName.endsWith("/")) {
        sb.append("/");
      }
    } else {
      // use . for non-URI named catalogs: prod.db.table
      sb.append(catalogName).append(".");
    }

    for (String level : identifier.namespace().levels()) {
      sb.append(level).append(".");
    }

    sb.append(identifier.name());

    return sb.toString();
  }
@Test
  public void fullTableNameWithDifferentValues() {
    String uriTypeCatalogName = "thrift://host:port/db.table";
    String namespace = "ns";
    String nameSpaceWithTwoLevels = "ns.l2";
    String tableName = "tbl";
    TableIdentifier tableIdentifier = TableIdentifier.of(namespace, tableName);
    assertThat(CatalogUtil.fullTableName(uriTypeCatalogName, tableIdentifier))
        .isEqualTo(uriTypeCatalogName + "/" + namespace + "." + tableName);

    tableIdentifier = TableIdentifier.of(nameSpaceWithTwoLevels, tableName);
    assertThat(CatalogUtil.fullTableName(uriTypeCatalogName, tableIdentifier))
        .isEqualTo(uriTypeCatalogName + "/" + nameSpaceWithTwoLevels + "." + tableName);

    assertThat(CatalogUtil.fullTableName(uriTypeCatalogName + "/", tableIdentifier))
        .isEqualTo(uriTypeCatalogName + "/" + nameSpaceWithTwoLevels + "." + tableName);

    String nonUriCatalogName = "test.db.catalog";
    assertThat(CatalogUtil.fullTableName(nonUriCatalogName, tableIdentifier))
        .isEqualTo(nonUriCatalogName + "." + nameSpaceWithTwoLevels + "." + tableName);

    String pathStyleCatalogName = "/test/db";
    assertThat(CatalogUtil.fullTableName(pathStyleCatalogName, tableIdentifier))
        .isEqualTo(pathStyleCatalogName + "/" + nameSpaceWithTwoLevels + "." + tableName);
  }