Is there a way in Azure Stream Analytics to create some aggregation with a custom state like Sparks mapWithState does?
Here is my scenario:
I have data from IoT devices containing the following fields:
- DeviceId
- Position
- Value
The data may arrive out of order.
Whenever a new packet arrives for a given DeviceId, I want to output the last n positions and values for that device. Like
Input:
{ "DeviceId": "A", "Position": 10, "Value": 100}
Output:
{ "DeviceId": "A", "Positions": [10], "Value": [100]}
Next Input:
{ "DeviceId": "A", "Position": 11, "Value": 101}
Output:
{ "DeviceId": "A", "Positions": [10, 11], "Value": [100, 101]}
Next Input:
{ "DeviceId": "A", "Position": 9, "Value": 99}
Output:
{ "DeviceId": "A", "Positions": [9, 10, 11], "Value": [9, 100, 101]}
In Spark Structured Streaming I would implement this using groupBy and mapWithState. Is there a way to implement this in ASA?