Secret Ninja Blog

Customer Experience Senior Directorしてます

Embulkでサンプルレコードを生成したいときの"config" input

embulk-outputプラグインを書いている時に、テスト用のJSONデータを生成するために、embulk-input-inlineを使っていたのですが、 Arrayの['xx', 'yyy']といった配列っぽいデータを生成させようとしたところ、inline pluginではかならずkey:valueのJSONを期待しているようで、生成されたデータが{xx:null, yyy:null}のようになり、うまくできませんでした。

しかし、embulk-input-inlineを使わなくても組み込みでconfigなるものがあり、 下記のように実現できるを教えてもらったので、メモ。

https://github.com/embulk/embulk/pull/678

in:
  type:
    name: config
  columns:
  - {name: id, type: long}
  - {name: names, type: json}
  values:
  - - [ 12, "['xxx','yyyy']" ]
out:
  type: stdout
2017-12-11 20:46:43.084 +0900 [INFO] (0001:transaction): Using local thread executor with max_threads=8 / output tasks 4 = input tasks 1 * 4
2017-12-11 20:46:43.098 +0900 [INFO] (0001:transaction): {done:  0 / 1, running: 0}
12,['xxx','yyyy']
2017-12-11 20:46:43.175 +0900 [INFO] (0001:transaction): {done:  1 / 1, running: 0}
2017-12-11 20:46:43.185 +0900 [INFO] (main): Committed.
2017-12-11 20:46:43.185 +0900 [INFO] (main): Next config diff: {"in":{},"out":{}}