dtle mapping

在job配置文件中,Table字段增加若干参数,详情参考4.3 作业配置,使用方法如下

schema mapping

单库mapping

job.json中ReplicateDoDb配置:

 "ReplicateDoDb":[
                    {
                        "TableSchema":"demo",
                        "TableSchemaRename":"demoRename"
                    }
                ],

单库mapping结果

src : demo
dest: demoRename

多库mapping

job.json中ReplicateDoDb配置:

 "ReplicateDoDb":[
                    { 
                        "TableSchemaRegex":"(\\w*)src(\\w*)",
                        "TableSchemaRename":"rename${1}",
                    }
                ],

多库mapping结果

src : test1src,test2src,test3src,cust
dest: renametest1, renametest2, renametest3

table mapping

单表mapping

job.json中ReplicateDoDb配置:

 "ReplicateDoDb":[
                    {
                        "TableSchema":"demo",
                        "Tables":[
                            {
                                "TableName":"testDemo",
                                "TableRename":"renameDemo"
                            }
                        ]
                    }
                ],

单表mapping结果

src : demo.testDemo
dest: demo.renameDemo

多表mapping

job.json中ReplicateDoDb配置:

 "ReplicateDoDb":[
                    {
                        "TableSchema":"demo",
                        "Tables":[
                            {
                                "TableRegex":"(\\w*)Shard(\\w*)",
                                "TableRename":"${1}Rename"
                            }
                        ]
                    }
                ],

多表mapping结果

src : demo.test1Shard,demo.test2Shard,demo.customer,demo.test3Shard
dest: demo.test1Rename,demo.test2Rename,demo.test3Rename

列mapping

src tables

create table demo.a (id int primary key, a int);
create table demo.b (id int primary key, b int);

dst table

create table demo.colmap (id int primary key auto_increment, val int);

使用 ColumnMapFromColumnMapTo参数,将表a和表b合并到表colmap。忽略原id,使用新的自增id作为主键。

注意:不支持自动创建目标表,需预先手动创建。

"ReplicateDoDb": [{
    "TableSchema":"demo",
    "Tables":[{
        "TableName": "a",
        "TableRename": "colmap",
        "ColumnMapFrom": ["a"],
        "ColumnMapTo": ["val"]        
    }, {
        "TableName": "b",
        "TableRename": "colmap",
        "ColumnMapFrom": ["b"],
        "ColumnMapTo": ["val"]
    }]
}],
"SkipCreateDbTable": true,
"DropTableIfExists": false,

参数说明

  • ColumnMapFrom: 从源表中, 依照指定的顺序, 提取全部列或部分列.
  • ColumnMapTo: 写入目标表时, 指定写入的列. 可为目标表全部列或部分列.
  • From和To的列数量必须相等.
    • 只填写ColumnMapFrom的用法现已deprecated.
  • 对于TwoWaySync双向任务, 反向任务会交换正向任务的ColumnMapFrom/ColumnMapTo

暂不支持使用正则表达式匹配列。

results matching ""

    No results matching ""