private Map<String, String> getPartitionSpec(Hive db, ASTNode node, TableName tableName) throws SemanticException {
    // if this node has only one child, then no partition spec specified.
    if (node.getChildCount() == 1) {
      return null;
    }

    // if ast has two children the 2nd child could be partition spec or columnName
    // if the ast has 3 children, the second *has to* be partition spec
    if (node.getChildCount() > 2 && (node.getChild(1).getType() != HiveParser.TOK_PARTSPEC)) {
      throw new SemanticException(node.getChild(1).getType() + " is not a partition specification");
    }

    if (node.getChild(1).getType() == HiveParser.TOK_PARTSPEC) {
      ASTNode partNode = (ASTNode) node.getChild(1);

      Table tab = null;
      try {
        tab = db.getTable(tableName.getNotEmptyDbTable());
      } catch (InvalidTableException e) {
        throw new SemanticException(ErrorMsg.INVALID_TABLE.getMsg(tableName.getNotEmptyDbTable()), e);
      } catch (HiveException e) {
        throw new SemanticException(e.getMessage(), e);
      }

      Map<String, String> partitionSpec = null;
      try {
        partitionSpec = getPartSpec(partNode);
        validateUnsupportedPartitionClause(tab, partitionSpec != null && !partitionSpec.isEmpty());
        partitionSpec = getValidatedPartSpec(tab, partNode, db.getConf(), false);
      } catch (SemanticException e) {
        // get exception in resolving partition it could be DESCRIBE table key
        // return null, continue processing for DESCRIBE table key
        return null;
      }

      if (partitionSpec != null) {
        Partition part = null;
        try {
          part = db.getPartition(tab, partitionSpec, false);
        } catch (HiveException e) {
          // if get exception in finding partition it could be DESCRIBE table key
          // return null, continue processing for DESCRIBE table key
          return null;
        }

        if (part == null) {
          throw new SemanticException(ErrorMsg.INVALID_PARTITION.getMsg(partitionSpec.toString()));
        }

        return partitionSpec;
      }
    }
    return null;
  }
Get the column path.
Return column name if exists, column could be DOT separated.
Example: lintString.$elem$.myint.
Return table name for column name if no column has been specified.
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/info/desc/DescTableAnalyzer.java