簡體   English   中英

Shift JOLT轉換-以下轉換面臨的問題

[英]Shift JOLT transformation - facing problem with below transformation

我試圖將下面的輸入json轉換為展平必要的列名稱及其值,同時保留所有元數據。

以下是我為CDC用例提供的輸入json

{
  "type": "update",
  "timestamp": 1558346256000,
  "binlog_filename": "mysql-bin-changelog.000889",
  "binlog_position": 635,
  "database": "books",
  "table_name": "publishers",
  "table_id": 111,
  "columns": [
    {
      "id": 1,
      "name": "id",
      "column_type": 4,
      "last_value": 2,
      "value": 2
    },
    {
      "id": 2,
      "name": "name",
      "column_type": 12,
      "last_value": "Suresh",
      "value": "Suresh123"
    },
    {
      "id": 3,
      "name": "email",
      "column_type": 12,
      "last_value": "Suresh@yahoo.com",
      "value": "Suresh@yahoo.com"
    }
  ]
}

以下是預期的輸出json

[
  {
    "type": "update",
    "timestamp": 1558346256000,
    "binlog_filename": "mysql-bin-changelog.000889",
    "binlog_position": 635,
    "database": "books",
    "table_name": "publishers",
    "table_id": 111,
    "columns": {
      "id": "2",
      "name": "Suresh123",
      "email": "Suresh@yahoo.com"
    }
  }
]

我嘗試了以下規范,可以從中檢索column對象,但無法檢索其余的元數據。

[
  {
    "operation": "shift",
    "spec": {
      "columns": {
        "*": {
          "@(value)": "[#1].@(1,name)"
        }
      }
    }
  }
]

任何線索將不勝感激。

我得到了上述轉換的JOLT規范。 我將其發布在這里,以防萬一有人偶然發現這樣的東西。

[
  {
    "operation": "shift",
    "spec": {
      "columns": {
        "*": {
          "@(value)": "columns.@(1,name)"
        }
      },
      "*": "&"
    }
  }
]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM