private static Triple<ImmutableList<Integer>, ImmutableSet<Integer>, ImmutableSet<Integer>> buildColIndxsFrmReloptHT(
      RelOptHiveTable relOptHTable, RelDataType scanRowType) {
    RelDataType relOptHtRowtype = relOptHTable.getRowType();
    Builder<Integer> neededColIndxsFrmReloptHTBldr = new ImmutableList.Builder<Integer>();
    ImmutableSet.Builder<Integer> virtualOrPartColIndxsInTSBldr =
        new ImmutableSet.Builder<Integer>();
    ImmutableSet.Builder<Integer> virtualColIndxsInTSBldr =
            new ImmutableSet.Builder<Integer>();

    Map<String, Integer> colNameToPosInReloptHT = HiveCalciteUtil
        .getRowColNameIndxMap(relOptHtRowtype.getFieldList());
    List<String> colNamesInScanRowType = scanRowType.getFieldNames();

    int partColStartPosInrelOptHtRowtype = relOptHTable.getNonPartColumns().size();
    int virtualColStartPosInrelOptHtRowtype =
        relOptHTable.getNonPartColumns().size() + relOptHTable.getPartColumns().size();
    int tmp;
    for (int i = 0; i < colNamesInScanRowType.size(); i++) {
      tmp = colNameToPosInReloptHT.get(colNamesInScanRowType.get(i));
      neededColIndxsFrmReloptHTBldr.add(tmp);
      if (tmp >= partColStartPosInrelOptHtRowtype) {
        // Part or virtual
        virtualOrPartColIndxsInTSBldr.add(i);
        if (tmp >= virtualColStartPosInrelOptHtRowtype) {
          // Virtual
          virtualColIndxsInTSBldr.add(i);
        }
      }
    }

    return Triple.of(
        neededColIndxsFrmReloptHTBldr.build(),
        virtualOrPartColIndxsInTSBldr.build(),
        virtualColIndxsInTSBldr.build());
  }
Copy TableScan operator with a new Row Schema. The new Row Schema can only
be a subset of this TS schema. Copies underlying RelOptHiveTable object
too.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveTableScan.java