Table toHiveTable() throws HCatException {
    Table newTable = new Table();
    newTable.setDbName(dbName);
    newTable.setTableName(tableName);
    if (tblProps != null) {
      newTable.setParameters(tblProps);
    }

    if (isExternal) {
      newTable.putToParameters("EXTERNAL", "TRUE");
      newTable.setTableType(TableType.EXTERNAL_TABLE.toString());
    } else {
      newTable.setTableType(TableType.MANAGED_TABLE.toString());
    }

    if (StringUtils.isNotBlank(this.comment)) {
      newTable.putToParameters("comment", comment);
    }

    if (newTable.getParameters().get("bucketing_version") == null) {
      newTable.putToParameters("bucketing_version", "2");
    }

    newTable.setSd(sd);
    if (partCols != null) {
      ArrayList<FieldSchema> hivePtnCols = new ArrayList<FieldSchema>();
      for (HCatFieldSchema fs : partCols) {
        hivePtnCols.add(HCatSchemaUtils.getFieldSchema(fs));
      }
      newTable.setPartitionKeys(hivePtnCols);
    }

    newTable.setCreateTime((int) (System.currentTimeMillis() / 1000));
    newTable.setLastAccessTimeIsSet(false);
    try {
      // TODO: Verify that this works for systems using UGI.doAs() (e.g. Oozie).
      newTable.setOwner(owner == null? getConf().getUser() : owner);
    }
    catch (Exception exception) {
      throw new HCatException("Unable to determine owner of table (" + dbName + "." + tableName
          + ") from HiveConf.");
    }
    return newTable;
  }
2 HCatTables are considered equivalent if {@code lhs.diff(rhs).equals(NO_DIFF) == true; }
hcatalog/webhcat/java-client/src/main/java/org/apache/hive/hcatalog/api/HCatTable.java