@PublicEvolving public class Csv extends FormatDescriptor
This descriptor aims to comply with RFC-4180 ("Common Format and MIME Type for Comma-Separated Values (CSV) Files") proposed by the Internet Engineering Task Force (IETF).
Note: This descriptor does not describe Flink's old non-standard CSV table source/sink. Currently, this descriptor can be used when writing to Kafka. The old one is still available under "org.apache.flink.table.descriptors.OldCsv" for stream/batch filesystem operations.
Constructor and Description |
---|
Csv()
Format descriptor for comma-separated values (CSV).
|
Modifier and Type | Method and Description |
---|---|
Csv |
allowComments()
Ignores comment lines that start with '#' (disabled by default).
|
Csv |
arrayElementDelimiter(String delimiter)
Sets the array element delimiter string for separating array or row element
values (";" by default).
|
Csv |
deriveSchema()
Derives the format schema from the table's schema.
|
Csv |
escapeCharacter(char escapeCharacter)
Sets the escape character for escaping values (disabled by default).
|
Csv |
fieldDelimiter(char delimiter)
Sets the field delimiter character (',' by default).
|
Csv |
ignoreParseErrors()
Skip fields and rows with parse errors instead of failing.
|
Csv |
lineDelimiter(String delimiter)
Sets the line delimiter ("\n" by default; otherwise "\r" or "\r\n" are allowed).
|
Csv |
nullLiteral(String nullLiteral)
Sets the null literal string that is interpreted as a null value (disabled by default).
|
Csv |
quoteCharacter(char quoteCharacter)
Sets the quote character for enclosing field values ('"' by default).
|
Csv |
schema(TypeInformation<Row> schemaType)
Sets the format schema with field names and the types.
|
protected Map<String,String> |
toFormatProperties()
Converts this descriptor into a set of format properties.
|
toProperties
toString
public Csv()
This descriptor aims to comply with RFC-4180 ("Common Format and MIME Type for Comma-Separated Values (CSV) Files) proposed by the Internet Engineering Task Force (IETF).
public Csv fieldDelimiter(char delimiter)
delimiter
- the field delimiter characterpublic Csv lineDelimiter(String delimiter)
delimiter
- the line delimiterpublic Csv quoteCharacter(char quoteCharacter)
quoteCharacter
- the quote characterpublic Csv allowComments()
public Csv ignoreParseErrors()
null
in case of errors. By default, an exception is thrown.public Csv arrayElementDelimiter(String delimiter)
delimiter
- the array element delimiterpublic Csv escapeCharacter(char escapeCharacter)
escapeCharacter
- escaping character (e.g. backslash)public Csv nullLiteral(String nullLiteral)
nullLiteral
- null literal (e.g. "null" or "n/a")public Csv schema(TypeInformation<Row> schemaType)
schemaType
- type information that describes the schemapublic Csv deriveSchema()
This allows for defining schema information only once.
The names, types, and fields' order of the format are determined by the table's schema. Time attributes are ignored if their origin is not a field. A "from" definition is interpreted as a field renaming in the format.
protected Map<String,String> toFormatProperties()
FormatDescriptor
FormatDescriptorValidator.FORMAT
.toFormatProperties
in class FormatDescriptor
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.