@VisibleForTesting
    protected static List<Integer> getQueryOutputIndices(List<Pair<Column, Integer>> mvColumnPairs) {
        return Streams
                .mapWithIndex(mvColumnPairs.stream(), (pair, idx) -> Pair.create(pair.second, (int) idx))
                .sorted(Comparator.comparingInt(x -> x.first))
                .map(x -> x.second)
                .collect(Collectors.toList());
    }
@Test
    public void testGetQueryOutputIndices() {
        checkQueryOutputIndices(Arrays.asList(1, 2, 0, 3), "2,0,1,3", true);
        checkQueryOutputIndices(Arrays.asList(0, 1, 2, 3), "0,1,2,3", false);
        checkQueryOutputIndices(Arrays.asList(3, 2, 1, 0), "3,2,1,0", true);
        checkQueryOutputIndices(Arrays.asList(1, 2, 3, 0), "3,0,1,2", true);
        checkQueryOutputIndices(Arrays.asList(0, 1), "0,1", false);
    }