private PrimitiveTypeInfo deriveResultTypeInfo() throws UDFArgumentException {
    if (predefinedTypeInfo instanceof PrimitiveTypeInfo && predefinedTypeInfo != null) {
      return (PrimitiveTypeInfo) predefinedTypeInfo;
    }
    PrimitiveTypeInfo left = (PrimitiveTypeInfo) TypeInfoUtils.getTypeInfoFromObjectInspector(leftOI);
    PrimitiveTypeInfo right = (PrimitiveTypeInfo) TypeInfoUtils.getTypeInfoFromObjectInspector(rightOI);
    if (!FunctionRegistry.isNumericType(left) || !FunctionRegistry.isNumericType(right)) {
      List<TypeInfo> argTypeInfos = new ArrayList<TypeInfo>(2);
      argTypeInfos.add(left);
      argTypeInfos.add(right);
      throw new NoMatchingMethodException(this.getClass(), argTypeInfos, null);
    }

    // If any of the type isn't exact, double is chosen.
    if (!FunctionRegistry.isExactNumericType(left) || !FunctionRegistry.isExactNumericType(right)) {
      return deriveResultApproxTypeInfo();
    }

    return deriveResultExactTypeInfo();
  }
Default implementation for deriving typeinfo instance for the operator result.

@param leftOI TypeInfo instance of the left operand
@param rightOI TypeInfo instance of the right operand
@return
@throws UDFArgumentException
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFBaseNumeric.java