What you will do
Move one list through three clear stages: calculate helper data, select suitable items, and build the final result. Run the example in CEL only and then in CEL + JSON.
How it works
Every call in the chain receives the preceding call's result. The first map() creates a map containing a code and calculated total. filter() keeps orders worth at least 100. The final map() returns only their codes.
orders
.map(order, {'code': order.code, 'total': order.price * order.quantity})
.filter(row, row.total >= 100.0)
.map(row, row.code)Evaluation step by step
- Order
A-10becomes{'code': 'A-10', 'total': 100.0}. - Order
B-20has a total of54.0, so the filter removes it. C-30has a total of120.0and remains.- The final transformation returns
['A-10', 'C-30'].
The helper map is an ordinary CEL value. It does not modify the input order and exists only in that stage's result.
Your task
- Run the prepared expression.
- Change the threshold from
100.0to110.0. - Return the whole helper map
rowinstead ofrow.codein the finalmap().
Expected observation: The higher threshold keeps only C-30. Removing the final projection also exposes the calculated totals.
Common mistake
A macro variable exists only inside that macro's body. The name order is not available in the following filter(); that stage works with a new item named row.
Show the explanation
The first map() returns a new list of maps. The next macro reads those maps, not the original orders.
Knowledge check
What kind of list enters filter(), and what kind of list does the final map() return?
Key takeaway
Read a longer expression from left to right as a data flow. Give every stage one understandable job.
Sources
CEL-DEV— official overview of CEL and its collection macros.CEL-LANG— official definition of lists, maps, and macros.CEL-GO-BIND— official documentation for the optionalcel.bind()extension used by the self-contained tab.