我可以在Azure流分析作业的同一输出中有多个查询吗?
例如
SELECT property1, property2 INTO Output1 WHERE Property3 ='Answer'
SELECT property4, property5 INTO Output1 WHERE Property3 ='Question'
首先合并结果,并使用WITH将组合命名为别名,然后从该表中选择进入输出。
https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/union-azure-stream-analytics
没有测试,但是应该给出一个主意:
WITH Combined AS (
SELECT property1, property2
FROM [input-hub]
WHERE Property3 ='Answer'
UNION
SELECT property4, property5
FROM [input-hub]
WHERE Property3 ='Question'
)
SELECT *
INTO [output-cosmos]
FROM Combined
另一种方法是在两个不同的ASA定义的输出接收器下添加相同的输出。例如,1个输出可以在ASA中作为OutPut1和Output2引用。
此方法的优点是能够控制数据输出的路径。尽管它可能到达相同的接收器,但可以将其配置为输出到其他路径或容器。
不,我刚刚尝试过,并且在开始工作时会触发此错误
Stream Analytics job has validation errors: Query compilation error: Duplicate output names are not allowed 'output-cosmos'.
我使用了以下查询
SELECT deviceId, pgm
INTO [output-cosmos]
FROM [input-hub]
WHERE pgm.running = true
SELECT deviceId, pgm
INTO [output-cosmos]
FROM [input-hub]
WHERE pgm.running = true