### Question:
SelectValueMapper implements ValueMapper<GenericRow, GenericRow> { @Override public GenericRow apply(final GenericRow row) { if (row == null) { return row; } final List<Object> newColumns = new ArrayList<>(); for (int i = 0; i < expressionPairList.size(); i++) { try { final int[] parameterIndexes = expressionEvaluators.get(i).getIndexes(); final Kudf[] kudfs = expressionEvaluators.get(i).getUdfs(); final Object[] parameterObjects = new Object[parameterIndexes.length]; for (int j = 0; j < parameterIndexes.length; j++) { if (parameterIndexes[j] < 0) { parameterObjects[j] = kudfs[j]; } else { parameterObjects[j] = typeEnforcer.enforceFieldType(parameterIndexes[j], row.getColumns() .get(parameterIndexes[j])); } } newColumns.add( expressionEvaluators.get(i).getExpressionEvaluator().evaluate(parameterObjects) ); } catch (Exception e) { log.error( "Error calculating column with index {} : {}", i, expressionPairList.get(i).getLeft(), e ); newColumns.add(null); } } return new GenericRow(newColumns); } SelectValueMapper(
      final GenericRowValueTypeEnforcer typeEnforcer,
      final List<Pair<String, Expression>> expressionPairList,
      final List<ExpressionMetadata> expressionEvaluators
  ); @Override GenericRow apply(final GenericRow row);  }### Answer:
@Test public void shouldSelectChosenColumns() throws Exception { final SelectValueMapper mapper = createMapper("SELECT col0, col2, col3 FROM test1 WHERE col0 > 100;"); final GenericRow transformed = mapper.apply(new GenericRow(Arrays.asList(1521834663L, "key1", 1L, "hi", "bye", 2.0F, "blah"))); assertThat(transformed, equalTo(new GenericRow(Arrays.asList(1L, "bye", 2.0F)))); }
@Test public void shouldApplyUdfsToColumns() throws Exception { final SelectValueMapper mapper = createMapper("SELECT col0, col1, col2, CEIL(col3) FROM test1 WHERE col0 > 100;"); final GenericRow row = mapper.apply(new GenericRow(Arrays.asList(1521834663L, "key1", 2L, "foo", "whatever", 6.9F, "boo", "hoo"))); assertThat(row, equalTo(new GenericRow(Arrays.asList(2L, "foo", "whatever", 7.0F)))); }