Allow UDF returning an array as parameter for 'CROSS APPLY GetArrayElements()'
The following query claims an error "Function 'GetArrayElements' requires a field of type 'array' as a parameter."
The function 'UDF.jsonify()' in fact is declared to return an array.
event.deviceid AS deviceid,
sensor.ArrayValue.sensorid AS sensorid,
CAST(sensor.ArrayValue.value AS FLOAT) AS value_number
FROM fromIoTHub AS event
CROSS APPLY GetArrayElements(UDF.jsonify(event.data)) AS sensor
I ran into this as well. I selected it from a CTE and this got around the issue.
With FooBar As (
UDF.rankNstuff(rankedItems) as Items,
SELECT Items.ArrayValue as something, FooBar.windowEnd
CROSS APPLY getarrayelements(FooBar.Items) as Items