fapaul commented on a change in pull request #17598:
URL: https://github.com/apache/flink/pull/17598#discussion_r792705881
##########
File path:
flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/CsvFileFormatFactory.java
##########
@@ -109,17 +110,21 @@ public CsvBulkDecodingFormat(ReadableConfig
formatOptions) {
final RowType physicalRowType = (RowType)
physicalDataType.getLogicalType();
final CsvSchema schema = buildCsvSchema(physicalRowType,
formatOptions);
+ final boolean ignoreParseErrors =
+ formatOptions.getOptional(IGNORE_PARSE_ERRORS).isPresent();
final Converter<JsonNode, RowData, Void> converter =
(Converter)
- new CsvToRowDataConverters(false)
+ new CsvToRowDataConverters(ignoreParseErrors)
.createRowConverter(projectedRowType,
true);
- return new StreamFormatAdapter<>(
+ CsvReaderFormat<RowData> csvReaderFormat =
new CsvReaderFormat<>(
new CsvMapper(),
schema,
JsonNode.class,
converter,
- context.createTypeInformation(projectedDataType)));
+ context.createTypeInformation(projectedDataType));
+ csvReaderFormat.setIgnoreParseErrors(ignoreParseErrors);
Review comment:
Good point. I think the best way here is to use the `wither` pattern
[1]. You can add a method like
`public CsvReaderFormat<T> withIgnoreParseErrors()`
that creates a new `CsvReaderFormat` with the flag that it ignores the
errors. By solely using `fromSchema` or `fromPojo` nothing changes. Users can
now do `CsvReaderFormat.fromPojo(Pojo.class).withIgnoreParseErrors()`
[1] https://projectlombok.org/features/With
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]