Skip to content

arrayJoin

Description

Returns a single string by joining the elements of an array using the specified delimiter.

  • The element type must be compatible with string conversion.
  • Supported element types include string, bool, number, interval, timestamp, regexp, and enum.

Syntax

Like many functions in DataPrime, arrayJoin supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.

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

Arguments

NameTypeRequiredDescription
arrayarraytrueThe array of values to join
delimiterstringtrueThe string delimiter used to join the array elements

Example

Use case: Build a readable message from array values

Suppose you have a list of users who logged in. Consider the following input:

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

By joining the users array with a delimiter, you can generate a human-readable string that combines the array elements with other fields.

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

Output

The result will include a new field msg with the joined string:

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