Quantcast
Channel: Developer topics
Viewing all articles
Browse latest Browse all 17937

Stream Analtycs Query Error

$
0
0

 

 With 
tmpGroup As (
SELECT
    Max(Cast(Iot.EventTime as Datetime)) as EventTime,
    Iot.BeaconMacId As beaconId,
    Iot.GatewayId as gatewayId,
    AVG(Iot.Rssi)   As RssiAvg,
    Count(*) As SignalCount,
    'BeaconKnownLocation' as Event
FROM
    FromIotHub as Iot
GROUP BY 
    Iot.BeaconMacId,
    Iot.GatewayId,
    TumblingWindow(ss,60)
),
tmpMaxValues as(
select 
     Max(Cast(tg.EventTime as Datetime)) as EventTime,
    tg.beaconId as beaconId,
    Max(tg.RssiAvg) as MaxRssiAvg,
    Max(tg.SignalCount) as MaxSignalCount
 from
tmpGroup tg
Group by 
    tg.beaconId,
    TumblingWindow(ss,60)
),

tmpGroupDifferences as(
select 
        g.*,
        (g.RssiAvg*-1)-(mv.MaxRssiAvg*-1) AS RssiDifference,
		(g.SignalCount)-(mv.MaxSignalCount) AS SignalDifference
from tmpMaxValues mv
inner join tmpGroup g on DATEDIFF(microsecond,mv, g) BETWEEN 0 AND 1 and g.beaconId = mv.beaconId 
),

tmpGroupDifferencesWithPoints as(
select
*,
(CASE WHEN (SignalDifference BETWEEN (3*-1) AND (3)) THEN 800 ELSE 0 END)+
			(100 + SignalDifference*4)+
			(CASE WHEN (RssiDifference BETWEEN (3*-1) AND (3)) THEN 400 ELSE 0 END)+
			(200 - RssiDifference*10)	AS TotalPoint
From tmpGroupDifferences
),

tmpBestPoint as(
SELECT
    beaconId,
    Max(TotalPoint) as BestPoint
From tmpGroupDifferencesWithPoints
Group by beaconId,
    TumblingWindow(ss,60)
),
SignalInfo as (
select TopOne() OVER (ORDER BY RssiAvg ASC) lastEvent
From tmpGroup
Group by     
TumblingWindow(ss,60)
)

select 
System.TimeStamp as timeForStream,
dp.EventTime,
dp.beaconId,dp.gatewayId, dp.totalPoint as totalpoint
Into OutPutDataWithRef
from tmpGroupDifferencesWithPoints dp
inner join tmpBestPoint bp on  DATEDIFF(microsecond,dp, bp) BETWEEN 0 AND 1 and
dp.BeaconId     = bp.BeaconId and 
dp.totalPoint   = bp.BestPoint
Union
Select System.TimeStamp as timeForStream,
lastEvent.EventTime as EventTime,
lastEvent.Event as BeaconId ,
'' as GatewayId,0 as totalpoint
From SignalInfo 

select 
System.TimeStamp as timeForStream,
     beaconId as beaconId,
     gatewayId as gatewayId,
     RssiAvg   As Rssi,
     SignalCount as totalpoint

 Into HamData From tmpGroup

select 
    system.timestamp as TimeForStream,
    Max(Cast(Iot.EventTime as Datetime)) as EventTime,
    Iot.BeaconMacId As beaconId,
    Min(Iot.Pedometer)   As FirstStep,
    Max(Iot.Pedometer)   As TotalStep,
    Max(Iot.Pedometer)-Min(Iot.Pedometer) As StepForMinute
Into
    StepInfo
FROM
    FromIotHub as Iot
GROUP BY 
    Iot.BeaconMacId,
    TumblingWindow(ss,60)
Having Min(Iot.Pedometer)>0

Have a nice day !

 

My problem is "Stream Analytics job has validation errors: Job will exceed the maximum amount of Event Hub Receivers."

 

But Use the Input "FromIotHub" just 2 times, how is it  working ?

I dont understand.

 

thanks for explanation.


Viewing all articles
Browse latest Browse all 17937

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>