欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

datax转换mongodb的数据到mysql遇到一个问题

程序员文章站 2022-05-21 09:11:30
...
mysqlmongodb数据

公司新项目需要从旧的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"
]
}
]
}
}
}
]
}
}