public static CsvIOParse<Row> parseRows(Schema schema, CSVFormat csvFormat) {
    CsvIOParseHelpers.validateCsvFormat(csvFormat);
    CsvIOParseHelpers.validateCsvFormatWithSchema(csvFormat, schema);
    RowCoder coder = RowCoder.of(schema);
    CsvIOParseConfiguration.Builder<Row> builder = CsvIOParseConfiguration.builder();
    builder.setCsvFormat(csvFormat).setSchema(schema).setCoder(coder).setFromRowFn(row -> row);
    return CsvIOParse.<Row>builder().setConfigBuilder(builder).build();
  }
@Test
  public void givenInvalidCsvFormat_throws() {
    Pipeline pipeline = Pipeline.create();
    CSVFormat csvFormat =
        CSVFormat.DEFAULT
            .withHeader("a_string", "an_integer", "a_double")
            .withAllowDuplicateHeaderNames(true);
    Schema schema =
        Schema.builder()
            .addStringField("a_string")
            .addInt32Field("an_integer")
            .addDoubleField("a_double")
            .build();
    assertThrows(IllegalArgumentException.class, () -> CsvIO.parseRows(schema, csvFormat));
    pipeline.run();
  }