locked
Compare value A with nested value B RRS feed

  • Question

  • I have a json string in nested format that send from device. Below are the data that been filter and pass directly to Blob Storage

    Container:-

    AZURE STREAM ANALYTICS QUERY

    SELECT
        DeviceID,
        DATEADD(HH,8,CAST(Timestamp AS DATETIME)) AS LocalTime,
        CAST(Temperature AS FLOAT) AS Temperature,
        CAST(TemperatureThreshold.Warning.Low AS FLOAT) AS TempWarningLow,
        CAST(TemperatureThreshold.Warning.High AS FLOAT) AS TempWarningHigh,
        CAST(TemperatureThreshold.Critical.Low AS FLOAT) AS TempCriticalLow,
        CAST(TemperatureThreshold.Critical.High AS FLOAT) AS TempCriticalHigh,
        CAST(Humidity AS FLOAT) AS Humidity,
        CAST(HumidityThreshold.Warning.Low AS FLOAT) AS HumidityWarningLow,
        CAST(HumidityThreshold.Warning.High AS FLOAT) AS HumidityWarningHigh,
        CAST(HumidityThreshold.Critical.Low AS FLOAT) AS HumidityCriticalLow,
        CAST(HumidityThreshold.Critical.High AS FLOAT) AS HumidityCriticalHigh
    INTO [DUMPBLOBTEST]
    FROM [incoming]

    AZURE BLOB STORAGE

    {"deviceid":"TEMP001","localtime":"2016-12-14T15:33:36.0000000Z","temperature":31.0,"tempwarninglow":20.0,"tempwarninghigh":80.0,"tempcriticallow":10.0,"tempcriticalhigh":90.0,"humidity":41.0,"humiditywarninglow":20.0,"humiditywarninghigh":80.0,"humiditycriticallow":10.0,"humiditycriticalhigh":90.0}

    There is one output that need to take care of incoming for notification. If incoming stream "Temperature" is more than "TempWarningLow" and "TempWarningHigh" so I will add value of Critical inside the query before sink to Event Hub. But how could I achieve this? I have try:-

    ...

    FROM incoming
    WHERE Temperature < TempWarningLow AND Temperature < TempCriticalLow

    But the result from Test sample data is 0 [no data on result]. Are this condition is correct for producing filter of condition "Sink to Event Hub if temperature exceed allow range"? Allow range is Not Warning and Not Critical on Low and High


    Code make everything

    Wednesday, December 14, 2016 9:00 AM