CSV
1 min read
This article introduces you to the usage and type mapping of the CSV format.
Background Information
The CSV format allows reading and writing CSV data based on the CSV structure. Currently, the CSV structure is derived based on the table structure.
Example of Use
An example of constructing a table using Kafka and Avro format is as follows.
SQL
1 CREATE TABLE user_behavior (
2 user_id BIGINT,
3 item_id BIGINT,
4 category_id BIGINT,
5 behavior STRING,
6 ts TIMESTAMP(3)
7 ) WITH (
8 'connector' = 'kafka',
9 'topic' = 'user_behavior',
10 'properties.bootstrap.servers' = 'localhost :9092',
11 'properties.group.id' = 'testGroup',
12 'format' = 'csv',
13 'csv.ignore-parse-errors' = 'true',
14 'csv.allow-comments' = 'true'
15 )Configuration Options
Type Mapping
Currently the structure of CSV is derived from the table structure. In Flink, CSV format data uses jackson databind API to parse CSV strings. The mapping relationship between Flink and CSV data types is as follows.
Type Mapping
For writing to object storage S3, currently it does not support writing files in CSV format. For specific reasons, see FLINK-30635.
Was this helpful?