Azure流分析如何处理多个输出表? [英] Azure Stream Analytics How to handle multiple output table?

查看:63
本文介绍了Azure流分析如何处理多个输出表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个ASA作业,还创建了一个输入别名和一个输出别名
像这样

I have created one ASA job and also created one input alias and one output alias
like this

我这样编辑查询部分

WITH 
[StreamData]
AS (
SELECT
    employee_id, 
    first_name,
    last_name,
    age,
    salary
FROM 
  [DeviceDataStream] 
WHERE
    [ObjectType] IS NULL -- Filter out device info and command responses
) 

SELECT
    employee_id, 
    first_name,
    last_name,
    age,
    salary
INTO
    [Telemetry]
FROM
    [StreamData]

我已经在SQL数据库中创建了表
像这样

I have created table in SQL database
like this

我从物联网设备输入的信息是这样的

and my input from IOT device is like this

{"employee_id":4,"first_name":"Joseph","last_name":"Marshal","age":34,"salary":890000}

到目前为止,一切正常.

up to this all things are working fine.

现在我想基于type将输入的JSON存储到不同的表中,而我的新输入的JSON将像这样

now I want to store my input JSON to different tables based on type and my new input JSON will be like this

{"type":"emp","employee_id":4,"first_name":"Joseph","last_name":"Marshal","age":34,"salary":890000}

不同的字段将具有不同的类型,并且按照我想将数据存储在不同的表中的方式,所以我需要什么更改以及在何处进行指导.谢谢

different fields will be there with different types and as per that I want to store data in different table, so what changes I need and where please guide me for that. thanks

推荐答案

最后我得到了一个简单的解决方案,我为每个输出表创建了一个输出

hey finally I got easy solution for this I have created one output for each output table

像这样

我的查询就是这样

WITH 
    [StreamData]
AS (
   SELECT
    *
    FROM 
      [DeviceDataStream] 
    WHERE
       [ObjectType] IS NULL -- Filter out device info and command responses
) 

SELECT
   EventProcessedUtcTime,
    PartitionId,
    EventEnqueuedUtcTime,
    IoTHub,
    employee_id, 
    first_name,
    last_name,
    age,
    salary
INTO
    [Telemetry]
FROM
    [StreamData]
WHERE type = 'emp'   --Table 1

SELECT
    EventProcessedUtcTime,
    PartitionId,
    EventEnqueuedUtcTime,
    PersonID, 
    FirstName,
    LastName,
    City,
    height
INTO
    [TelemetryP]
FROM
    [StreamData]
WHERE type = 'prsn'  --Table 2

这篇关于Azure流分析如何处理多个输出表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆