How to merge two strings when both of them are not null

Hello!
I just started exploring Druid and I’ve managed to set up a successful ingestion from my Kafka. However I ran into a problem that I couldn’t figure out how to solve. So I thought I’d ask here.

The solution is probably really simple but I couldn’t find anything helpful in the documentation.

In my data I have two fields width and height, and I’d like to concat them to get a resolution field. However the fields are sometimes null so a simple concat threw and error in the GUI. I tried doing this:

if(deviceInfo.width != null && deviceInfo.height != null, concat(deviceInfo.width, “x”, deviceInfo.height), “unknown”)

But that also returned an error. So probably my syntax is incorrect but I couldn’t find anything on how to properly syntax the druid expression.

Thankful for any help figuring this out!
/Tim

What are the errors you are referring to? Can you send the whole query?

Also, this (if you are using SQL):

https://druid.apache.org/docs/latest/querying/sql.html#null-values

I had another look at it and clearly I had confused how to reference strings and columns.
I was attempting to do this in the Load Data part of the GUI (under transform). I turned out that the correct expression I needed was
concat(“deviceInfo.width”,‘x’, “deviceInfo.height”)
and that it won’t concat null fields.
The error I was getting when trying to use the expression I got above was “Error: undefined” and nothing else so didn’t get much insight from that.

Best regards,
Tim

Small typo, the phrase "The error I was getting when trying to use the expression I got above " was referring to the expression I wrote in my first mail, and not the the mail I just wrote, that one worked fine! :slight_smile: