I am receiving incoming messages as
{"set":
{"datapoints":[
{"name":"abc","type":"int","value":151},
{"name":"pqr","type":"int","value":246}],
"timestamp":"2024-03-07T10:42:55.902Z"
}
}
I want to transform this Message to another format as below:
{
"vals": [
{
"name": "abc",
"type": "Int",
"timestamp": "2024-03-07T10:07:35.3405950Z",
"val": "0"
},
{
"name": "pqr",
"type": "Int",
"timestamp": "2024-03-07T10:07:35.3406800Z",
"val": "0"
}
]
}
The timestamp attribute should be part of each datapoint object in the result vals array. i wrote the Rule SQL
SELECT
(SELECT 0 AS id,
dp.name AS name dp.type AS type,
set.timestamp as ts,
dp.value AS val
FROM dset.datapoints as dp) AS vals
FROM 'topic/data/+/#'
I am unable to get timestamp value. How can I add timestamp value to each datapoints element?