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,
  • 可以不填写ColumnMapTo的情况:目标表列个数和顺序与 ColumnMapFrom 一致、不使用目标表自增ID和默认值。
  • 如果使用ColumnMapTo,则其中列必须和ColumnMapFrom一一对应。

暂不支持列正则匹配。

results matching ""

    No results matching ""