Concat two nested fields from JSON in Spec

I want to concat two fields from the below JSON
event_name: “login”,
attributes : { button_action: “aaa” }
event_name: “login”,
attributes : { button_text: “bbb” }

where event_name would be same but attributes may have button_action or button_text attrinute. But in Druid datasource I want to concat both attributes and ingest into one column like below

event_name | merged_attribute

login | aaa
login | bbb

The problem is coming because I want to merge two nested fields. Is there a way I can merge them without introducing two column(button_action and button_text) and then merge them up.

I’ve tried nvl(button_action,button_text) in the transforms section of transformSpec but no luck. Also, concat is not working here.


Confessing that I’ve never played with this much — but is it possible to use a flattenSpec and then some kind of concat in the Path expression?

Can we use nested path in JsonPath like below?
“concat(”$.attribute.button_action", “$.attribute.button_text”)"

concatenation will not work in flattenSpec but it works in transformSpec. For concatenation to work in transformSpec we need to give it columns but not nested path of those columns.

So, it means I have to introduce two new columns then I can concat them into third column.

I was trying to concat without introducing new columns(button_action and button_text). Rather to just use paths to nested attributes and concat into new column like below

“concat(”$.attribute.button_action", “$.attribute.button_text”)"

Ah damn that’s a real shame… I presume because the flattenSpec just expects a true path and not a function…

is there a way to use nested paths in transformSpec like in flattenSpec ?

The list of expressions is here:

I don’t think you will be able to get to the “raw” JSON – but then I was just wondering if you may be able to do something creative like get the JSON in as a string, or maybe parse it into a multi-value dimension that you could then use as a transformation or at query time…

I was also wondering (never tried this) if you could use flattenSpec with the actual paths, but then not include the dimensions in your dimensionsSpec list (so it doesn’t get actually created as columns) – but then still refer to those columns from your flattenSpec in a concat function in the transformSpec…? I don’t know if that’s possible…