presto-main/src/main/java/io/prestosql/sql/planner/iterative/rule/PruneValuesColumns.java/PruneValuesColumns/pushDownProjectOff
class PruneValuesColumns:    @Override
    protected Optional<PlanNode> pushDownProjectOff(PlanNodeIdAllocator idAllocator, ValuesNode valuesNode, Set<Symbol> referencedOutputs)
    {
        List<Symbol> newOutputs = filteredCopy(valuesNode.getOutputSymbols(), referencedOutputs::contains);

        // for each output of project, the corresponding column in the values node
        int[] mapping = new int[newOutputs.size()];
        for (int i = 0; i < mapping.length; i++) {
            mapping[i] = valuesNode.getOutputSymbols().indexOf(newOutputs.get(i));
        }

        ImmutableList.Builder<List<Expression>> rowsBuilder = ImmutableList.builder();
        for (List<Expression> row : valuesNode.getRows()) {
            rowsBuilder.add(Arrays.stream(mapping)
                    .mapToObj(row::get)
                    .collect(Collectors.toList()));
        }

        return Optional.of(new ValuesNode(valuesNode.getId(), newOutputs, rowsBuilder.build()));
    }