Rule definition with schema_decode in foreach

When I try to iterate on a schema encoded message in my rules I just cannot figure it out what the proper syntax is. I Tries


FOREACH 
  schema_decode('sparkplug_b', payload, 'Payload').metrics
FROM
  "spBv1.0/#"

but it does not work. Is there any trick how can access the “metrics” field (array) from the select statement, if the payload needs to be decoded first?

OK, I slept and with a fresh mind, I figured it out. I leave the solution here just in case (I’ve used map_get)


FOREACH 

map_get('metrics', schema_decode('sparkplug_b', payload, 'Payload') ) as metric
FROM

  "spBv1.0/#"