fluent-plugin-sql icon indicating copy to clipboard operation
fluent-plugin-sql copied to clipboard

How to Map a json inside a json to column

Open Happylinzy opened this issue 2 years ago • 1 comments

If I have a JSON {"id":7, "name":"bob"}, I can use column_mapping 'id:id, name:name' .

But, for example, I have a JSON like this : {"id":{"myid":7}, "name":"bob"}

How can I map myid to the column id?

Happylinzy avatar Mar 07 '22 09:03 Happylinzy

use the trasnfrom record to extract the fields , then use the new vars to inster into the table

ex: @type record_transformer enable_ruby true data ${record.to_json} # Convert full JSON log data to string under "data" created_at ${Time.now.utc.iso8601} # Store current UTC time

change record.to_json with record["filed"] or something like this, double check the ruby syntax

then in the table:

table table_name column_mapping 'data:data,created_at:created_at'

ghaythta avatar May 06 '24 11:05 ghaythta