The pack_array function in APL creates an array from individual values or expressions. You can use this function to group related data into a single field, which can simplify handling and querying of data collections. It is especially useful when working with nested data structures or aggregating data into arrays for further processing.

For users of other query languages

If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.

Usage

Syntax

pack_array(value1, value2, ..., valueN)

Parameters

ParameterDescription
value1The first value to include in the array.
value2The second value to include in the array.
...Additional values to include in the array.
valueNThe last value to include in the array.

Returns

An array containing the specified values in the order they are provided.

Use case example

Use pack_array to consolidate span data into an array for a trace summary.

Query

['otel-demo-traces']
| extend span_summary = pack_array(['service.name'], kind, duration)

Run in Playground

Output

service.namekinddurationspan_summary
frontendserver123ms[“frontend”, “server”, “123ms”]

This query creates a concise representation of span details.