static Map<Integer, Schema.Field> mapFieldPositions(CSVFormat format, Schema schema) {
    List<String> header = Arrays.asList(format.getHeader());
    Map<Integer, Schema.Field> indexToFieldMap = new HashMap<>();
    for (Schema.Field field : schema.getFields()) {
      int index = getIndex(header, field);
      if (index >= 0) {
        indexToFieldMap.put(index, field);
      }
    }
    return indexToFieldMap;
  }
@Test
  public void givenSchemaContainsNullableFieldTypes() {
    Schema schema =
        Schema.builder()
            .addNullableStringField("a_string")
            .addDoubleField("a_double")
            .addInt32Field("an_integer")
            .addDateTimeField("a_datetime")
            .addNullableStringField("another_string")
            .build();
    ImmutableMap<Integer, Schema.Field> want =
        ImmutableMap.of(
            0,
            schema.getField("an_integer"),
            1,
            schema.getField("a_double"),
            2,
            schema.getField("a_datetime"));
    Map<Integer, Schema.Field> got =
        CsvIOParseHelpers.mapFieldPositions(
            csvFormat().withHeader("an_integer", "a_double", "a_datetime"), schema);
    assertEquals(want, got);
  }