use of org.apache.flink.formats.csv.CsvFormatOptions.ALLOW_COMMENTS in project flink by apache.
the class CsvFileFormatFactory method buildCsvSchema.
private static CsvSchema buildCsvSchema(RowType rowType, ReadableConfig options) {
final CsvSchema csvSchema = CsvRowSchemaConverter.convert(rowType);
final CsvSchema.Builder csvBuilder = csvSchema.rebuild();
// format properties
options.getOptional(FIELD_DELIMITER).map(s -> StringEscapeUtils.unescapeJava(s).charAt(0)).ifPresent(csvBuilder::setColumnSeparator);
if (options.get(DISABLE_QUOTE_CHARACTER)) {
csvBuilder.disableQuoteChar();
} else {
options.getOptional(QUOTE_CHARACTER).map(s -> s.charAt(0)).ifPresent(csvBuilder::setQuoteChar);
}
options.getOptional(ALLOW_COMMENTS).ifPresent(csvBuilder::setAllowComments);
options.getOptional(ARRAY_ELEMENT_DELIMITER).ifPresent(csvBuilder::setArrayElementSeparator);
options.getOptional(ESCAPE_CHARACTER).map(s -> s.charAt(0)).ifPresent(csvBuilder::setEscapeChar);
options.getOptional(NULL_LITERAL).ifPresent(csvBuilder::setNullValue);
return csvBuilder.build();
}
use of org.apache.flink.formats.csv.CsvFormatOptions.ALLOW_COMMENTS in project flink-mirror by flink-ci.
the class CsvFileFormatFactory method buildCsvSchema.
private static CsvSchema buildCsvSchema(RowType rowType, ReadableConfig options) {
final CsvSchema csvSchema = CsvRowSchemaConverter.convert(rowType);
final CsvSchema.Builder csvBuilder = csvSchema.rebuild();
// format properties
options.getOptional(FIELD_DELIMITER).map(s -> StringEscapeUtils.unescapeJava(s).charAt(0)).ifPresent(csvBuilder::setColumnSeparator);
if (options.get(DISABLE_QUOTE_CHARACTER)) {
csvBuilder.disableQuoteChar();
} else {
options.getOptional(QUOTE_CHARACTER).map(s -> s.charAt(0)).ifPresent(csvBuilder::setQuoteChar);
}
options.getOptional(ALLOW_COMMENTS).ifPresent(csvBuilder::setAllowComments);
options.getOptional(ARRAY_ELEMENT_DELIMITER).ifPresent(csvBuilder::setArrayElementSeparator);
options.getOptional(ESCAPE_CHARACTER).map(s -> s.charAt(0)).ifPresent(csvBuilder::setEscapeChar);
options.getOptional(NULL_LITERAL).ifPresent(csvBuilder::setNullValue);
return csvBuilder.build();
}
use of org.apache.flink.formats.csv.CsvFormatOptions.ALLOW_COMMENTS in project flink by splunk.
the class CsvFileFormatFactory method buildCsvSchema.
private static CsvSchema buildCsvSchema(RowType rowType, ReadableConfig options) {
final CsvSchema csvSchema = CsvRowSchemaConverter.convert(rowType);
final CsvSchema.Builder csvBuilder = csvSchema.rebuild();
// format properties
options.getOptional(FIELD_DELIMITER).map(s -> StringEscapeUtils.unescapeJava(s).charAt(0)).ifPresent(csvBuilder::setColumnSeparator);
if (options.get(DISABLE_QUOTE_CHARACTER)) {
csvBuilder.disableQuoteChar();
} else {
options.getOptional(QUOTE_CHARACTER).map(s -> s.charAt(0)).ifPresent(csvBuilder::setQuoteChar);
}
options.getOptional(ALLOW_COMMENTS).ifPresent(csvBuilder::setAllowComments);
options.getOptional(ARRAY_ELEMENT_DELIMITER).ifPresent(csvBuilder::setArrayElementSeparator);
options.getOptional(ESCAPE_CHARACTER).map(s -> s.charAt(0)).ifPresent(csvBuilder::setEscapeChar);
options.getOptional(NULL_LITERAL).ifPresent(csvBuilder::setNullValue);
return csvBuilder.build();
}
Aggregations