public static MessageType getSchemaByIndex(MessageType schema, List<String> colNames, List<Integer> colIndexes) {
    List<Type> schemaTypes = new ArrayList<Type>();

    for (Integer i : colIndexes) {
      if (i < colNames.size()) {
        if (i < schema.getFieldCount()) {
          schemaTypes.add(schema.getType(i));
        } else {
          //prefixing with '_mask_' to ensure no conflict with named
          //columns in the file schema
          schemaTypes.add(
            Types.optional(PrimitiveTypeName.BINARY).named("_mask_" + colNames.get(i)));
        }
      }
    }

    return new MessageType(schema.getName(), schemaTypes);
  }
Searches column names by indexes on a given Parquet file schema, and returns its corresponded
Parquet schema types.

@param schema Message schema where to search for column names.
@param colNames List of column names.
@param colIndexes List of column indexes.
@return A MessageType object of the column names found.
ql/src/java/org/apache/hadoop/hive/ql/io/parquet/read/DataWritableReadSupport.java