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

    Map<String, FieldNode> prunedCols = getPrunedNestedColumns(nestedColumnPaths);
    for (Integer i : colIndexes) {
      if (i < colNames.size()) {
        if (i < schema.getFieldCount()) {
          Type t = schema.getType(i);
          String tn = t.getName().toLowerCase();
          if (!prunedCols.containsKey(tn)) {
            schemaTypes.add(schema.getType(i));
          } else {
            if (t.isPrimitive()) {
              // For primitive type, add directly.
              schemaTypes.add(t);
            } else {
              // For group type, we need to build the projected group type with required leaves
              List<Type> g =
                projectLeafTypes(Arrays.asList(t), Arrays.asList(prunedCols.get(tn)));
              if (!g.isEmpty()) {
                schemaTypes.addAll(g);
              }
            }
          }
        } 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);
  }
Generate the projected schema from colIndexes and nested column paths. If the column is
contained by colIndex, it will be added directly, otherwise it will build a group type which
contains all required sub types using nestedColumnPaths.
@param schema original schema
@param colNames
@param colIndexes the index of needed columns
@param nestedColumnPaths the paths for nested columns
@return
ql/src/java/org/apache/hadoop/hive/ql/io/parquet/read/DataWritableReadSupport.java