我有一个 json 文件,如下所示:
{“imei”:{“imei”:“358174069248418F”,“imeiBinary”:“NYF0BpJIQY8 =”,“imeiNotEncoded”:“358174069248418”,“有效”:1},“dataPackets”:[[“msy.mxp.datapacket” .AlarmNotification",{"version": 1, "id": 21, "op": 2,"sizeDynamic": 0, "alarmStatus": 4}],["msy.mxp.datapacket.IOStatus",{"版本": 1,"id": 15, "op": 2,"sizeDynamic": 0,"ioStatus": 135,"ioDirections": 120}], ["msy.mxp.datapacket.LogicalStatus",{"版本": 1,"id": 16, "op": 2,"sizeDynamic": 0,"逻辑状态": 5} ],[ "msy.mxp.datapacket.Position", {"版本": 1," id":19,"op":2,"纬度":40.835243,"经度":14.246057,"高度":40,"速度":0,"航向":68,"gpsNumSatellite":5,"glonassNumSatellite" :1,“fixValid”:1,“timeValid”:1,“wgs84degMinFormat”:1,“glonass”:1,“fixMode”:3,“时间戳”:{“timeSecFrom1Gen2000”:925560202,“时间”:1490648755000} , "sizeDynamic": 0} ] ]}
我正在阅读以下查询:
WITH Datapackets AS
(
SELECT imei.imei as imei,
persistent as persistent,
[timestamp].[time] as input_time,
compressed as compressed,
GetArrayElement(dataPackets, 3) as position
FROM h24
), one as(
SELECT *,
GetRecordPropertyValue (GetArrayElement(position,1), 'timestamp') as position_timestamp --1st
from Datapackets
), two as (
select
imei,
GetRecordPropertyValue (GetArrayElement(position,1), 'op') as position_OP,
[position_timestamp].[time] as position_time,
dateadd(S, [position_timestamp].[timeSecFrom1Gen2000], '1970-01-01') as timing,
GetRecordPropertyValue (GetArrayElement(position,1), 'latitude') as position_latitude,
GetRecordPropertyValue (GetArrayElement(position,1), 'longitude') as position_longitude,
GetRecordPropertyValue (GetArrayElement(position,1), 'altitude') as position_altitude,
GetRecordPropertyValue (GetArrayElement(position,1), 'speed') as position_speed
from one) SELECT * from two
现在我想让窗口按 30 秒滚动分组,如下所示,但我有一个问题,告诉我输入文件“two”不允许使用时间戳属性,这里是我使用的查询
WITH Datapackets AS
(
SELECT imei.imei as imei,
persistent as persistent,
[timestamp].[time] as input_time,
compressed as compressed,
GetArrayElement(dataPackets, 3) as position
FROM h24
), one as(
SELECT *,
GetRecordPropertyValue (GetArrayElement(position,1), 'timestamp') as position_timestamp --1st
from Datapackets
), two as (
select
imei,
GetRecordPropertyValue (GetArrayElement(position,1), 'op') as position_OP,
[position_timestamp].[time] as position_time,
dateadd(S, [position_timestamp].[timeSecFrom1Gen2000], '1970-01-01') as timing,
GetRecordPropertyValue (GetArrayElement(position,1), 'latitude') as position_latitude,
GetRecordPropertyValue (GetArrayElement(position,1), 'longitude') as position_longitude,
GetRecordPropertyValue (GetArrayElement(position,1), 'altitude') as position_altitude,
GetRecordPropertyValue (GetArrayElement(position,1), 'speed') as position_speed
from one) SELECT imei, System.TimeStamp AS 'start', Avg(position_speed), max(position_latitude)
FROM two TIMESTAMP BY TIMING GROUP BY imei, TumblingWindow(duration(second, 30))
错误出现在最后两行(FROM two TIMESTAMP BY TIMING),
************** 更新,,经过更多调查后,我发现我只能在输入中使用选项时间戳,并且只有在我要为以下内容制作自定义时间戳时才必须使用它事件。通常,默认情况下它们会带有到达时间的时间戳(https://msdn.microsoft.com/en-us/library/mt573293.aspx)
现在我的问题是如何使用记录在 Json 文件中的第三级数组中的时间字段为我的事件添加时间戳,以便能够进行聚合。
关于如何处理这个问题的任何建议,谢谢