Upsolver
Search…
FIRST_ARRAY
Returns the first array of values seen in events within the time window. ‌Unlike FIRST_K, this aggregation will not aggregate values across different events.

Syntax

FIRST_ARRAY(VALUE)

Arguments

VALUE: An expression of any type. ‌

Returns

The result is an array of the same type as VALUE.

Example

Data

1
[
2
{
3
"id":1,
4
"name":"Jimmy",
5
"emails":[
8
]
9
}{
10
"id":2,
11
"name":"Peter",
12
"emails":[
14
]
15
}{
16
"id":1,
17
"name":"Jimmy",
18
"emails":[
21
]
22
}{
23
"id":3,
24
"name":"Link",
25
"emails":[
26
27
]
28
}
29
]
Copied!

Query

Display the earliest contents of a field for each key:
1
SELECT
2
data.id AS id:BIGINT,
3
FIRST_ARRAY(data.emails[]) AS first_array_data_emails:STRING
4
FROM
5
"FIRST_ARRAY_DATA"
6
GROUP BY
7
data.id
Copied!

Results

1
{
2
"id":2,
3
"first_array_data_emails":[
5
]
6
}{
7
"id":3
8
}{
9
"id":1,
10
"first_array_data_emails":[
13
]
14
}
Copied!

Dialog

Last modified 8mo ago