Skip to content

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

arrayJoin(array: array<T>, delimiter: string): string

Arguments

NameTypeRequiredDescription
arrayarray of type TtrueT must be either string, bool, number, interval, timestamp, regexp or enum
delimiterstringtrueThe delimiter on which to join each element of the array

Example - Build a message from array data

Consider the following document:

{
    "users": ["Emma", "Ofri", "Marci", "Zev"]
    "action": "LOGIN"
}

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:

create msg from `Users {users.arrayJoin(',')} performed action {action}`

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}`