public static DecimalTypeInfo getDecimalTypeTypeInfo(ASTNode node)
      throws SemanticException {
    if (node.getChildCount() > 2) {
      throw new SemanticException("Bad params for type decimal");
    }

    int precision = HiveDecimal.USER_DEFAULT_PRECISION;
    int scale = HiveDecimal.USER_DEFAULT_SCALE;

    if (node.getChildCount() >= 1) {
      String precStr = node.getChild(0).getText();
      precision = Integer.parseInt(precStr);
    }

    if (node.getChildCount() == 2) {
      String scaleStr = node.getChild(1).getText();
      scale = Integer.parseInt(scaleStr);
    }

    return TypeInfoFactory.getDecimalTypeInfo(precision, scale);
  }
Performs a descent of the leftmost branch of a tree, stopping when either a
node with a non-null token is found or the leaf level is encountered.

@param tree
         candidate node from which to start searching

@return node at which descent stopped
ql/src/java/org/apache/hadoop/hive/ql/parse/ParseUtils.java