public static long getLastReplicationId(HCatPartition ptn, @Nullable HCatTable parentTable) {
    Map<String,String> parameters = ptn.getParameters();
    if (parameters != null){
      if (parameters.containsKey(REPL_STATE_ID)){
        return Long.parseLong(parameters.get(REPL_STATE_ID));
      }
    }

    if (parentTable != null){
      return getLastReplicationId(parentTable);
    }
    return 0l; // default is to return earliest possible state.
  }
Gets the last known replication state of the provided partition.
This is applicable only if it is the destination of a replication
and has had data replicated into it via imports previously.
If that is not available, but parent table is provided,
defaults to parent table's replication state. If that is also
unknown, defaults to 0.
hcatalog/webhcat/java-client/src/main/java/org/apache/hive/hcatalog/api/repl/ReplicationUtils.java