arrayJoin - Converts an array into a string with some delimiter
arrayJoin
will join every element of an array on some delimiter, and return a string
.
Syntax
Arguments
Name | Type | Required | Description |
---|---|---|---|
array | array of type T | true | T must be either string , bool , number , interval , timestamp , regexp or enum |
delimiter | string | true | The delimiter on which to join each element of the array |
Example - Build a message from array data
Consider the following document:
This document indicates that four users logged in. We can use arrayJoin
to build a human readable message from the users
array and the action
field:
This will result in the following document:
{
"users": ["Emma", "Ofri", "Marci", "Zev"]
"action": "LOGIN",
"msg": "Users Emma,Ofri,Marci,Zev performed action LOGIN"
}
Try it yourself
Open up the log explore screen and paste the following command:
create users from ['Chris', 'John', 'Stacy']
| create action from 'LOGIN'
| create msg from `Users {users.arrayJoin(',')} performed action {action}`
Theme
Light