azure-stream-analyticsstream-analytics

How to check null values in JSON property in stream analytics?


I am Passing the following Json input from Eventhub to Stream Analytics.

{"meter_totalcycleenergy":null,"Test2": 20}, {"meter_totalcycleenergy":40,"Test2":20}

But the job is failing stating the error.

Encountered error trying to write 1 event(s): Cannot convert from property 'meter_totalcycleenergy' of type 'System.String' to column 'meter_totalcycleenergy' of type 'System.Single'.

Error Image How to handle such conditions.

I think Json nulls are not exactly SQL NULLs, so what would be the proper way to check for null values in a query?

Datatype of meter_totalcycleenergy is float in my database.


Solution

  • You can use is not null. For eg:

    select *
    from input
    where meter_totalcycleenergy is not null