Skip to content

Commit 9b07746

Browse files
authored
ticdc: add header line for CSV protocol (#20478)
1 parent a549d93 commit 9b07746

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

ticdc/ticdc-csv.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ null = '\N'
2929
include-commit-ts = true
3030
binary-encoding-method = 'base64'
3131
output-old-value = false
32+
output-field-header = false # 从 v9.0.0 开始引入
3233
```
3334

3435
## 数据保存的事务性约束
@@ -52,6 +53,12 @@ CSV 文件中,单行的每一列定义如下:
5253
- 第五列:`is-update`,该列仅在 `output-old-value` 为 true 时存在,用于标识该行变更来自 Update 事件(值为 true),还是来自 Insert/Delete 事件(值为 false)。
5354
- 第六列至最后一列:变更数据的列,可为一列或多列。
5455

56+
当配置中 `output-field-header = true` 时,CSV 文件将包含一个表头行,表头行的列名如下:
57+
58+
| 第一列 | 第二列 | 第三列 | 第四列(可选) | 第五列(可选) | 第六列 | ... | 最后一列 |
59+
| --- | --- | --- | --- | --- | --- | --- | --- |
60+
| `ticdc-meta$operation` | `ticdc-meta$table` | `ticdc-meta$schema` | `ticdc-meta$commit-ts` | `ticdc-meta$is-update` | 涉及数据变更的第一列的列名 | ... | 涉及数据变更的最后一列的列名 |
61+
5562
假设某张表 `hr.employee` 的定义如下:
5663

5764
```sql
@@ -86,6 +93,19 @@ CREATE TABLE `employee` (
8693
"I","employee","hr",433305438660591630,true,102,"Alex","Alice","2018-06-15","Beijing"
8794
```
8895

96+
当配置中 `include-commit-ts = true``output-old-value = true``output-field-header = true` 时,该表上的 DML 事件以 CSV 格式存储后如下所示:
97+
98+
```csv
99+
ticdc-meta$operation,ticdc-meta$table,ticdc-meta$schema,ticdc-meta$commit-ts,ticdc-meta$is-update,Id,LastName,FirstName,HireDate,OfficeLocation
100+
"I","employee","hr",433305438660591626,false,101,"Smith","Bob","2014-06-04","New York"
101+
"D","employee","hr",433305438660591627,true,101,"Smith","Bob","2015-10-08","Shanghai"
102+
"I","employee","hr",433305438660591627,true,101,"Smith","Bob","2015-10-08","Los Angeles"
103+
"D","employee","hr",433305438660591629,false,101,"Smith","Bob","2017-03-13","Dallas"
104+
"I","employee","hr",433305438660591630,false,102,"Alex","Alice","2017-03-14","Shanghai"
105+
"D","employee","hr",433305438660591630,true,102,"Alex","Alice","2017-03-14","Beijing"
106+
"I","employee","hr",433305438660591630,true,102,"Alex","Alice","2018-06-15","Beijing"
107+
```
108+
89109
## 数据类型映射
90110

91111
| MySQL 类型 | CSV 类型 | 示例 | 描述 |

0 commit comments

Comments
 (0)