时间:2021-07-01 10:21:17 帮助过:280人阅读
公司新项目需要从旧的mongodb库了把数据导入到新的mysql库。在用淘宝的datax工具导入数据的时候遇到以下的问题
mongodb的是数据很多都是一个document里不是所有字段都的值都有.
例如:user = [{“name”:”张三”,”id”:”0000001″},
{“age”:12,”id”:”0000002″},
{“name”:”王二麻子”,”age”:13,”id”:”0000003″}]
这样在datax调度Job的时候回报读入和写入的字段数量不同。
请问该如何解决?
我的job.json配置如下:
{
"job": {
"setting": {
"speed": {
"channel": 2
}
},
"content": [
{
"reader": {
"name": "mongodbreader",
"parameter": {
"address": ["192.168.1.1:27017"],
"userName": "",
"userPassword": "",
"dbName": "test",
"collectionName": "usertest"
"column": [
{
"name": "name",
"type": "string"
},
{
"name": "age",
"type": "int"
},
{
"name": "id",
"type": "string"
}
]
}
},
"writer": {
"name": "mysqlwriter",
"parameter": {
"writeMode": "insert",
"username": "user",
"password": "123456",
"column": [
"id",
"name",
"age"
],
"session": [
"set session sql_mode='ANSI'"
],
"preSql": [
"delete from user"
],
"connection": [
{
"jdbcUrl": "jdbc:mysql://192.168.1.1:3306/datax?useUnicode=true&characterEncoding=utf-8",
"table": [
"user"
]
}
]
}
}
}
]
}
}