Skip to main content
Version: v1.8.0

map

Aggregate Function

map aggregate map values into a single map

Synopsis

map(|{any:any}|) -> |{any:any}|

Description

The map aggregate function combines map inputs into a single map output. If map receives multiple values for the same key, the last value received is retained. If the input keys or values vary in type, the return type will be a map of union of those types.

Examples

Combine a sequence of records into a map:

echo '{stock:"APPL",price:145.03} {stock:"GOOG",price:87.07}' | zq -z 'map(|{stock:price}|)' -

=>

|{"APPL":145.03,"GOOG":87.07}|

Continuous collection over a simple sequence:

echo '|{"APPL":145.03}| |{"GOOG":87.07}| |{"APPL":150.13}|' | zq -z 'yield map(this)' -

=>

|{"APPL":145.03}|
|{"APPL":145.03,"GOOG":87.07}|
|{"APPL":150.13,"GOOG":87.07}|