public static boolean containsSqlType(RelDataType type, SqlTypeName typeName) {
    Objects.requireNonNull(typeName);
    if (type == null) {
      return false;
    }
    if (typeName.equals(type.getSqlTypeName())) {
      return true;
    }
    if (type.isStruct()) {
      return type.getFieldList().stream().map(RelDataTypeField::getType)
          .anyMatch(t -> HiveSqlTypeUtil.containsSqlType(t, typeName));
    }
    return containsSqlType(type.getComponentType(), typeName) || containsSqlType(type.getKeyType(), typeName)
        || containsSqlType(type.getValueType(), typeName);
  }
Returns whether the type contains the specified type name. If the type is a struct, map, or collection then
containment is applied recursively on the respective parts (fields, component, key, value).
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveSqlTypeUtil.java