【发布时间】:2017-01-13 19:28:09
【问题描述】:
我正在尝试在 ASA(Azure 流分析)中编写一个查询,其中输入是一个看起来像这样的 json 行消息
{
"DeviceId": "Device3",
"DateTime": "2016-09-05T13:23:04.5444423",
"Value": [ 1, 0, 1, 0, 0, 1, 0 ]
}
我想要做的是执行 Unpivot,以便数据出现在表单上
create table LightBeacon (
DeviceId int primary key not null,
EventDateTime datetime not null,
LightBeaconId varchar(25) not null,
LightBeaconState SmallInt not null
)
但似乎 ASA 不支持 SQL Unpivot 函数,并且左侧还有多选语句,例如
with
DataUnArray as (
SELECT DeviceId, DateTime as EventDateTime
, GetArrayElement(Value, 0) as LigthBeacon01
, GetArrayElement(Value, 1) as LigthBeacon02
, GetArrayElement(Value, 2) as LigthBeacon03
, GetArrayElement(Value, 3) as LigthBeacon04
, GetArrayElement(Value, 4) as LigthBeacon05
, GetArrayElement(Value, 5) as LigthBeacon06
, GetArrayElement(Value, 6) as LigthBeacon07
FROM DataIoT
where DeviceId = 'Device3'),
DataUnpivot as (
select DeviceId, EventDateTime, 'LigthBeacon01' as LigthBeaconId, LigthBeacon01 as LigthBeaconState from DataUnArray
Union All select DeviceId, EventDateTime, 'LigthBeacon02' as LigthBeaconId, LigthBeacon02 as LigthBeaconState from DataUnArray
Union All select DeviceId, EventDateTime, 'LigthBeacon03' as LigthBeaconId, LigthBeacon03 as LigthBeaconState from DataUnArray
Union All select DeviceId, EventDateTime, 'LigthBeacon04' as LigthBeaconId, LigthBeacon04 as LigthBeaconState from DataUnArray
Union All select DeviceId, EventDateTime, 'LigthBeacon05' as LigthBeaconId, LigthBeacon05 as LigthBeaconState from DataUnArray
Union All select DeviceId, EventDateTime, 'LigthBeacon06' as LigthBeaconId, LigthBeacon06 as LigthBeaconState from DataUnArray
Union All select DeviceId, EventDateTime, 'LigthBeacon07' as LigthBeaconId, LigthBeacon07 as LigthBeaconState from DataUnArray
)
select DeviceId, EventDateTime, LigthBeaconId, LigthBeaconState
into DataLakeCSV
from DataUnpivot
ASA 查询未能启动并出现以下错误:
流分析作业存在验证错误:作业将超过 事件中心接收器的最大数量
如果我将它减少到 5 个信标——它会起作用!!!那么如何编写一个可以在一个 unpivot 中处理超过 5 列的 ASA 查询呢?
\比约恩
【问题讨论】:
标签: azure iot unpivot azure-stream-analytics