DataWorks百问百答50:MongoDB的Object字段如何同步到ODPS?

数据


original字段为Object,下面是MongoDB里的数据,应该如何同步至ODPS?

{
  "_id" : ObjectId("yyyyy"),
  "tags" : [ ],
  "status" : "delete",
  "category" : "xx",
  "chainId" : "xxxxx",
  "filename" : "xxxxx",
  "name" : "xxxx",
  "createdTime" : ISODate("xxxxxx"),
  "fileType" : "xxxx",
  "bucket" : "xxxx",
  "appId" : "xxxxx",
  "path" : "2018/07/18",
  "directory" : "r8xdcsdfdwH",
  "creator" : "XcdcdscdRF",
  "modifiedTime" : ISODate("2018-07-18T08:10:37.2.cdcdcd"),
  "sort" : cqfcerferf,
  "original" : {
    "creator" : "54cced",
    "modifiedTime" : ISODate("2018-07-16T11:01:19.cedcwedweZ")
  },
  "id" : "7cwecwecea",
  "extendData" : {

  },
  "fileSize" : 4235345440,
  "meta" : {
    "ImageHeight" : "454325345",
    "ImageWidth" : "452345348"
  }
}

配置json案例:

注意:不能用大写只识别小写的配置

  • DOCUMENT.STRING改为document.string
  • DOCUMENT.DATE改为document.date
{
    "type": "job",
    "steps": [
        {
            "stepType": "mongodb",
            "parameter": {
                "datasource": "数据源名",
                "column": [
                 
                    {
                        "name": "staddswds",
                        "type": "string"
                    },
                    {
                        "name": "sorsdst",
                        "type": "int"
                    },
                    {
                        "name": "original.creator",
                        "type": "document.string"//注意小写
                    },
                    {
                        "name": "original.modifiedTime",
                        "type": "document.date"//注意小写
                    }
                ],
                "collectionName": "files"
            },
            "name": "Reader",
            "category": "reader"
        },
        {
            "stepType": "odps",
            "parameter": {
                "partition": "ds=${bizdate}",
                "truncate": true,
                "compress": false,
                "datasource": "数据源名",
                "column": [
                    "staddswds",
                    "sorsdst",
                    "original_creator",
                    "original_modifiedTime"
                ],
                "emptyAsNull": false,
                "guid": "odps.sssssdf",
                "table": "表名"
            },
            "name": "Writer",
            "category": "writer"
        }
    ],
    "version": "2.0",
    "order": {
        "hops": [
            {
                "from": "Reader",
                "to": "Writer"
            }
        ]
    },
    "setting": {
        "jvmOption": "",
        "errorLimit": {
            "record": "0"
        },
        "speed": {
            "throttle": false,
            "concurrent": 3
        }
    }
}

DataWorks百问百答历史记录 请点击这里查看>>

更多DataWorks技术和产品信息,欢迎加入【DataWorks钉钉交流群】

上一篇:DataWorks百问百答46:数据质量的“规则” VS 运维中心的“规则”,有什么不同和关联之处呢?


下一篇:DataWorks百问百答45:如何设置数据分析项目?