pack_array
This page explains how to use the pack_array function in APL.
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’s especially useful when working with nested data structures or aggregating data into arrays for further processing.
Usage
Syntax
pack_array(value1, value2, ..., valueN)Parameters
| Parameter | Description |
|---|---|
value1 | The first value to include in the array. |
value2 | The second value to include in the array. |
... | Additional values to include in the array. |
valueN | The last value to include in the array. |
Returns
An array containing the specified values in the order they're 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)Output
| service.name | kind | duration | span_summary |
|---|---|---|---|
| frontend | server | 123ms | ["frontend", "server", "123ms"] |
This query creates a concise representation of span details.
List of related functions
- array_slice: Extracts a subset of elements from an array.
- array_concat: Combines multiple arrays.
- array_length: Returns the number of elements in an array.