17 Aug 2025 01:01 PM
Hi,
From one of the tasks of the DQL course in university:
Starting with the below DQL Query, what data type are the following fields:
Afterwards, modify the query to cast the k8s.container.name field to a String.
I checked the requested types and the type of the k8s.container.name is an array. I tried the following:
fetch events
| filter event.kind == "DAVIS_PROBLEM"
| fields k8s.container.name
| filterOut isNull(k8s.container.name)
| fieldsAdd test = asString(k8s.container.name)
The value of the test column is null. I searched in the documentation, but didn't find anything like arrayToString(arr, delimiter) or similar.
Can you help me with this?
Regards, Deni
Solved! Go to Solution.
17 Aug 2025 07:04 PM
Unfortunately there is no function where you can specify new delimiter. There is however toString function. This example should explain how it works and how to achieve what you need:
data record(arr=array("s1","s2","s3"))
| fieldsAdd merged = toString(arr)
| fieldsAdd merged2 = replaceString(merged,"""["""","")
| fieldsAdd merged2 = replaceString(merged2,""""]""","")
| fieldsAdd merged2 = replaceString(merged2,"""", """","/")
17 Aug 2025 07:54 PM
Ahaaa, I tried asString, but now I see in the documentation that all as... functions just verify the type and return null otherwise. If I want to cast, I need to use the to... functions — in this case toString.
Thanks also for the extra tips on how to set a custom delimiter 🙂