Hello
It's a bit hard to actually grasp what the function should do but I was able to do something similar.
I got the same error message until I split up the query:
First, make sure the output of the function is 'array':
My function is not that impressive:
Call the function as an UDF:
Finally, I did not call the function on the same line as the cross apply but added the function as extra columns to an tempory table:
I recommend using the VS Code extension for Stream Analytics so you can test your function and job locally.
If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.