public static final CacheTag createParentCacheTag(CacheTag tag) {
    if (tag == null) {
      throw new IllegalArgumentException();
    }

    if (tag instanceof MultiPartitionCacheTag) {
      MultiPartitionCacheTag multiPartitionCacheTag = (MultiPartitionCacheTag) tag;
      if (multiPartitionCacheTag.partitionDesc.length > 2) {
        String[] subList = new String[multiPartitionCacheTag.partitionDesc.length - 1];
        for (int i = 0; i < subList.length; ++i) {
          subList[i] = multiPartitionCacheTag.partitionDesc[i];
        }
        return new MultiPartitionCacheTag(multiPartitionCacheTag.tableName, subList);
      } else {
        return new SinglePartitionCacheTag(multiPartitionCacheTag.tableName,
            multiPartitionCacheTag.partitionDesc[0]);
      }
    }

    if (tag instanceof SinglePartitionCacheTag) {
      return new TableCacheTag(tag.tableName);
    } else {
      // DB level
      int ix = tag.tableName.indexOf(".");
      if (ix <= 0) {
        return null;
      }
      return new TableCacheTag(tag.tableName.substring(0, ix));
    }

  }
Constructs a (fake) parent CacheTag instance by walking back in the hierarchy i.e. stepping
from inner to outer partition levels, then producing a CacheTag for the table and finally
the DB.
storage-api/src/java/org/apache/hadoop/hive/common/io/CacheTag.java