public static TypeInfo getCommonClass(TypeInfo a, TypeInfo b) {
    if (a.equals(b)) {
      return a;
    }

    // We try to infer a common primitive category
    PrimitiveCategory commonCat = getPrimitiveCommonCategory(a, b);
    if (commonCat != null) {
      return getTypeInfoForPrimitiveCategory((PrimitiveTypeInfo)a, (PrimitiveTypeInfo)b, commonCat);
    }
    // It is not primitive; check if it is a struct and we can infer a common class
    if (a.getCategory() == Category.STRUCT && b.getCategory() == Category.STRUCT) {
      return getCommonClassForStruct((StructTypeInfo)a, (StructTypeInfo)b,
          (type1, type2) -> getCommonClass(type1, type2));
    }
    return null;
  }
Find a common class that objects of both TypeInfo a and TypeInfo b can
convert to. This is used for places other than comparison.

The common class of string and double is string.

@return null if no common class could be found.
ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java