As we have seen, lookupResult is an array with just one element: the element at index 0 in the array. We need to move all the fields under this array element directly under the JSON payload. This is done field by field using the rename operation.
For example, the following operation renames the existing sensorType field directly under the JSON payload:
rename => {"[lookupResult][0][sensorType]" => "sensorType"}
We do this for all the looked-up fields that are returned by the SQL query.