用于天蓝色流分析的Java脚本用户定义函数,用于按时间间隔进行分组

时间:2017-11-13 12:12:42

标签: javascript azure user-defined-functions azure-stream-analytics

在Azure流分析作业中,我有一个SELECT查询,它以下列结构为我提供输出:

ASA输出结构

ASA output structure

我想按照15秒的时间间隔来获得平均速度和最后的纬度/经度。我设法通过AZA查询来完成它但由于ASA中的“timestamp by”属性,我无法使用之前的SELECT语句在同一个Query作业中进行。

所以我认为一个选项可能是让Java脚本用户定义的函数这样做。

这是我拥有的聚合的ASA查询,我想要类似的UDF:

with one as (SELECT
    [imei],[timing],[position_latitude],[position_longitude],[position_speed],
    CAST(LAST([position_latitude]) OVER ( partition by imei LIMIT DURATION(minute, 1) WHEN position_latitude IS NOT NULL) as float ) as Lst_lat,
    CAST(LAST([position_longitude]) OVER ( partition by imei LIMIT DURATION(minute, 1) WHEN position_longitude IS NOT NULL ) as float ) as Lst_lon
FROM
    eventhublevelII TIMESTAMP BY Timing )

SELECT imei, System.Timestamp as Time_Group,
AVG(POSITION_SPEED) as AVG_SPEED,
max(Lst_lat) as last_lat,
max(Lst_lon) as last_lon
into SQL
from one 
GROUP BY imei, TumblingWindow(second, 30)

正在读取此文件:

  

{ “IMEI”: “351631046708985F”, “position_op”:2 “position_time”:1490603299000, “定时”: “2017-03-27T08:28:19.0000000Z”, “position_latitude”:0.0, “position_longitude” :0.0, “position_altitude”:180, “position_speed”:0 “position_course”:0 “position_glonass”:1, “position_gpsnumsatellite”:0 “position_glonassnumsatellite”:0 “position_fixvalid”:0 “position_timevalid”:1 “position_wgs84degminformat”:1, “position_fixmode”:1}

所需的输出如下表所示:

汇总表输出

aggregation table output

任何想法或建议都将不胜感激。

0 个答案:

没有答案